Showing posts with label assembly. Show all posts
Showing posts with label assembly. Show all posts

Wednesday, March 21, 2012

FileIOPermission for Custom Assembly

I am using a strong-named custom assembly to which I have assigned 'Full
Trsut' in both the rspreviewpolicy.config as well as rssrvrpolicy.config.
Now, I have introduced a function in my assembly that requires reading some
settings from a file...The error message I see when executing that function
is "Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089 failed".
If the assembly already has Full Trust permissions, then should it not have
full access to all resources? Or do I need to create a FileIOPermission set?
I tried the latter, but it does not seem to work for me either...Please
help...You would need to give the data extension permissions for File IO
e.g.
<PermissionSet class="abcg"
verion="1" Name="FileSharePermissionSet"
<IPermission class="FileIOPermission"
version="1"
Unrestricted="true" />
</PermissionSet>
"Aparna" wrote:
> I am using a strong-named custom assembly to which I have assigned 'Full
> Trsut' in both the rspreviewpolicy.config as well as rssrvrpolicy.config.
> Now, I have introduced a function in my assembly that requires reading some
> settings from a file...The error message I see when executing that function
> is "Request for the permission of type
> System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
> Culture=neutral, PublicKeyToken=b77a5c561934e089 failed".
> If the assembly already has Full Trust permissions, then should it not have
> full access to all resources? Or do I need to create a FileIOPermission set?
> I tried the latter, but it does not seem to work for me either...Please
> help...
>|||You see, I tried doing something similar and it is not working.
Here is my named permission set:
<PermissionSet
class="NamedPermissionSet"
version="1"
Unrestricted="true"
Name="TestPermissionSet" >
<IPermission
class="FileIOPermission"
version="1"
Unrestricted="true"/>
<IPermission
class="EnvironmentPermission"
version="1"
Unrestricted="true"/>
</PermissionSet>
I added both FileIOPermission as well as Environment Permission because the
code reads a file and also calls Environment.ExpandEnvironmentVariables().
The code group looks as follows:
<CodeGroup class="UnionCodeGroup"
version="1"
PermissionSetName="TestPermissionSet"
Name="TestCode">
<IMembershipCondition
class="StrongNameMembershipCondition"
version="1"
PublicKeyBlob="blahblahblah"/>
</CodeGroup>
Still no luck!!
~Aparna.
"Mac" wrote:
> You would need to give the data extension permissions for File IO
> e.g.
> <PermissionSet class="abcg"
> verion="1" Name="FileSharePermissionSet"
> <IPermission class="FileIOPermission"
> version="1"
> Unrestricted="true" />
> </PermissionSet>
>
> "Aparna" wrote:
> > I am using a strong-named custom assembly to which I have assigned 'Full
> > Trsut' in both the rspreviewpolicy.config as well as rssrvrpolicy.config.
> > Now, I have introduced a function in my assembly that requires reading some
> > settings from a file...The error message I see when executing that function
> > is "Request for the permission of type
> > System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
> > Culture=neutral, PublicKeyToken=b77a5c561934e089 failed".
> >
> > If the assembly already has Full Trust permissions, then should it not have
> > full access to all resources? Or do I need to create a FileIOPermission set?
> > I tried the latter, but it does not seem to work for me either...Please
> > help...
> >sql

FileIOPermission

I got my custom assembly working fine until I add writing to a log
file. Then I get a FileIOPermission error.
I have the following code in my policy file:
<PermissionSet
class="NamedPermissionSet"
version="1"
Name="ReportHelperFilePermissionSet"
Description="A special permission set that grants read access to my
currency rates file.">
<IPermission
class="FileIOPermission"
version="1"
All="C:\ReportHelper.log"/>
<IPermission
class="SecurityPermission"
version="1"
Flags="Execution, Assertion"/>
</PermissionSet>
<CodeGroup class="UnionCodeGroup"
version="1"
PermissionSetName="ReportHelperFilePermissionSet"
Name="MyNewCodeGroup"
Description="A special code group for my custom assembly.">
<IMembershipCondition
class="UrlMembershipCondition"
version="1"
Url="D:\Program Files\Microsoft SQL Server\MSSQL\Reporting
Services\ReportServer\bin\ReportHelper.dll"/>
</CodeGroup>
<CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="AWCLibrary">
<IMembershipCondition
class="UrlMembershipCondition"
version="1"
Url="D:\Program Files\Microsoft SQL Server\MSSQL\Reporting
Services\ReportServer\bin\ReportHelper.dll"/>
</CodeGroup>
I write to my log file as follows:
public static void WriteLogFile(String msg)
{
FileIOPermission perm1 = new
FileIOPermission(FileIOPermissionAccess.Write, @."C:\ReportHelper.log");
perm1.Assert();
//try
//{
FileStream fs = new FileStream(@."C:\ReportHelper.log",
FileMode.OpenOrCreate, FileAccess.ReadWrite);
StreamWriter w = new StreamWriter(fs);
w.BaseStream.Seek(0, SeekOrigin.End);
w.Write("{0} {1} ", DateTime.Now.ToLongTimeString(),
DateTime.Now.ToLongDateString());
w.Write(msg + "\r\n");
w.Flush();
w.Close();
}
What am I missing here? Any help would be appreciated.
Thanks!Check this
http://www.c-sharpcorner.com/Code/2005/June/CustomAssemblyinRS.asp
HTH
If still you face the issue, let me know (bkkrishnan [at] hotmail [dot] com)
Thanks
Balaji
Siwy wrote:
>I got my custom assembly working fine until I add writing to a log
>file. Then I get a FileIOPermission error.
>I have the following code in my policy file:
><PermissionSet
> class="NamedPermissionSet"
> version="1"
> Name="ReportHelperFilePermissionSet"
> Description="A special permission set that grants read access to my
>currency rates file.">
> <IPermission
> class="FileIOPermission"
> version="1"
> All="C:\ReportHelper.log"/>
> <IPermission
> class="SecurityPermission"
> version="1"
> Flags="Execution, Assertion"/>
></PermissionSet>
><CodeGroup class="UnionCodeGroup"
> version="1"
> PermissionSetName="ReportHelperFilePermissionSet"
> Name="MyNewCodeGroup"
> Description="A special code group for my custom assembly.">
> <IMembershipCondition
> class="UrlMembershipCondition"
> version="1"
> Url="D:\Program Files\Microsoft SQL Server\MSSQL\Reporting
>Services\ReportServer\bin\ReportHelper.dll"/>
></CodeGroup>
><CodeGroup
> class="UnionCodeGroup"
> version="1"
> PermissionSetName="FullTrust"
> Name="AWCLibrary">
> <IMembershipCondition
> class="UrlMembershipCondition"
> version="1"
> Url="D:\Program Files\Microsoft SQL Server\MSSQL\Reporting
>Services\ReportServer\bin\ReportHelper.dll"/>
></CodeGroup>
>I write to my log file as follows:
>public static void WriteLogFile(String msg)
> {
> FileIOPermission perm1 = new
>FileIOPermission(FileIOPermissionAccess.Write, @."C:\ReportHelper.log");
> perm1.Assert();
> //try
> //{
> FileStream fs = new FileStream(@."C:\ReportHelper.log",
>FileMode.OpenOrCreate, FileAccess.ReadWrite);
> StreamWriter w = new StreamWriter(fs);
> w.BaseStream.Seek(0, SeekOrigin.End);
> w.Write("{0} {1} ", DateTime.Now.ToLongTimeString(),
> DateTime.Now.ToLongDateString());
> w.Write(msg + "\r\n");
> w.Flush();
> w.Close();
> }
>What am I missing here? Any help would be appreciated.
>Thanks!
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-reporting/200507/1|||Hi Balaji,
I followed the article and it still doesn't work. I added [assembly:
AllowPartiallyTrustedCallers] to my assembly and removed extra
PermissionSet and CodeGroup sections from my policy file (I left the
"FullTrust" one) and I still get FileIOPermission error.
Thanks,
Kris
BALAJI via SQLMonster.com wrote:
> Check this
> http://www.c-sharpcorner.com/Code/2005/June/CustomAssemblyinRS.asp
> HTH
> If still you face the issue, let me know (bkkrishnan [at] hotmail [dot] com)
> Thanks
> Balaji
>
> Siwy wrote:
> >I got my custom assembly working fine until I add writing to a log
> >file. Then I get a FileIOPermission error.
> >
> >I have the following code in my policy file:
> >
> ><PermissionSet
> > class="NamedPermissionSet"
> > version="1"
> > Name="ReportHelperFilePermissionSet"
> > Description="A special permission set that grants read access to my
> >currency rates file.">
> > <IPermission
> > class="FileIOPermission"
> > version="1"
> > All="C:\ReportHelper.log"/>
> > <IPermission
> > class="SecurityPermission"
> > version="1"
> > Flags="Execution, Assertion"/>
> ></PermissionSet>
> >
> ><CodeGroup class="UnionCodeGroup"
> > version="1"
> > PermissionSetName="ReportHelperFilePermissionSet"
> > Name="MyNewCodeGroup"
> > Description="A special code group for my custom assembly.">
> > <IMembershipCondition
> > class="UrlMembershipCondition"
> > version="1"
> > Url="D:\Program Files\Microsoft SQL Server\MSSQL\Reporting
> >Services\ReportServer\bin\ReportHelper.dll"/>
> ></CodeGroup>
> ><CodeGroup
> > class="UnionCodeGroup"
> > version="1"
> > PermissionSetName="FullTrust"
> > Name="AWCLibrary">
> > <IMembershipCondition
> > class="UrlMembershipCondition"
> > version="1"
> > Url="D:\Program Files\Microsoft SQL Server\MSSQL\Reporting
> >Services\ReportServer\bin\ReportHelper.dll"/>
> ></CodeGroup>
> >
> >I write to my log file as follows:
> >
> >public static void WriteLogFile(String msg)
> > {
> > FileIOPermission perm1 = new
> >FileIOPermission(FileIOPermissionAccess.Write, @."C:\ReportHelper.log");
> > perm1.Assert();
> > //try
> > //{
> > FileStream fs = new FileStream(@."C:\ReportHelper.log",
> >FileMode.OpenOrCreate, FileAccess.ReadWrite);
> > StreamWriter w = new StreamWriter(fs);
> > w.BaseStream.Seek(0, SeekOrigin.End);
> > w.Write("{0} {1} ", DateTime.Now.ToLongTimeString(),
> > DateTime.Now.ToLongDateString());
> > w.Write(msg + "\r\n");
> > w.Flush();
> >
> > w.Close();
> > }
> >
> >What am I missing here? Any help would be appreciated.
> >
> >Thanks!
>
> --
> Message posted via SQLMonster.com
> http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-reporting/200507/1

Wednesday, March 7, 2012

File System Access With Custom Assembly Method

Hello All,
I am building a dashboard report that will read through the file system
for a record's document folder on our server and report to the user if
there are any files missing in the directory. I am using a custom
assembly to house the method. When using the assembly in the dev
environment, everything works just fine. When the report is deployed
to the server, the assembly seems to work fine, but on closer
inspection, it looks like I cannot read the file system. Can someone
point me to a link that can bypass this (safely)? Do I need to suck it
up and create an ASP.NET app that does the same thing?
Thanks
JeffHi Jeff.
You need to change the "rssrvpolicy.config" to permit file access to your
assembly. In Visual Studio you have all permissions, but running on the
report server permission checks is performed.
In "rssrvpolicy.config" you can see several codegroups giving other
assemblies certain permissions. The file is found in "%SQL
SERVER%\MSSQL\Reporting Services\ReportServer"
You can put you CodeGroup below the one ending with Url="$CodeGen$/*". Se
sample:
<CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust">
<IMembershipCondition
class="UrlMembershipCondition"
version="1"
Url="$CodeGen$/*"
/>
</CodeGroup>
<CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="MyCodeGroup"
Description="Code group for my assembly">
<IMembershipCondition
class="UrlMembershipCondition"
version="1"
Url="C:\Program Files\Microsoft SQL Server\MSSQL\Reporting
Services\ReportServer\bin\MyAssembly.MyNamespace.MyClass.dll"
/>
</CodeGroup>
This way you give you assemmbly Full thrust. To limit persmission to file
access you can change PermissionSet to "FileIOPermission".
Kind regards
Martin Bring (Sogeti AB)
*****************
"jeffjones176@.gmail.com" wrote:
> Hello All,
> I am building a dashboard report that will read through the file system
> for a record's document folder on our server and report to the user if
> there are any files missing in the directory. I am using a custom
> assembly to house the method. When using the assembly in the dev
> environment, everything works just fine. When the report is deployed
> to the server, the assembly seems to work fine, but on closer
> inspection, it looks like I cannot read the file system. Can someone
> point me to a link that can bypass this (safely)? Do I need to suck it
> up and create an ASP.NET app that does the same thing?
> Thanks
> Jeff
>

Friday, February 24, 2012

File or assembly name Interop.DTS, or one of its dependencies, was not found.

I am trying to execute a DTS via COM according to the KB article
http://support.microsoft.com/?kbid=321525
but I am getting the exception "File or assembly name Interop.DTS, or one of
its dependencies, was not found." which is obviously a file not found
exception. I have sql server 2000 installed locally and I can run the
package from enterprise manager. Anyone got any ideas why I am getting when
I have the correct reference in the c# .net project?
--
Cheers
Ollie Riches
http://www.phoneanalyser.net
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.Is the Interop.DTS.dll in your application bin folder? This should get
generated when you build your project.
You might also check out the examples at
http://sqldev.net/dts/ExecutePackage.htm
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Ollie Riches" <ollie.riches@.phoneanalser.net> wrote in message
news:OLP4UckJFHA.588@.TK2MSFTNGP15.phx.gbl...
>I am trying to execute a DTS via COM according to the KB article
> http://support.microsoft.com/?kbid=321525
> but I am getting the exception "File or assembly name Interop.DTS, or one
> of
> its dependencies, was not found." which is obviously a file not found
> exception. I have sql server 2000 installed locally and I can run the
> package from enterprise manager. Anyone got any ideas why I am getting
> when
> I have the correct reference in the c# .net project?
> --
> Cheers
> Ollie Riches
> http://www.phoneanalyser.net
> Disclaimer: Opinions expressed in this forum are my own, and not
> representative of my employer.
> I do not answer questions on behalf of my employer. I'm just a programmer
> helping programmers.
>|||yeap it was noob error, no dll in the bin directory :)
Ollie
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:#$jJFpkJFHA.2136@.TK2MSFTNGP14.phx.gbl...
> Is the Interop.DTS.dll in your application bin folder? This should get
> generated when you build your project.
> You might also check out the examples at
> http://sqldev.net/dts/ExecutePackage.htm
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Ollie Riches" <ollie.riches@.phoneanalser.net> wrote in message
> news:OLP4UckJFHA.588@.TK2MSFTNGP15.phx.gbl...
> >I am trying to execute a DTS via COM according to the KB article
> >
> > http://support.microsoft.com/?kbid=321525
> >
> > but I am getting the exception "File or assembly name Interop.DTS, or
one
> > of
> > its dependencies, was not found." which is obviously a file not found
> > exception. I have sql server 2000 installed locally and I can run the
> > package from enterprise manager. Anyone got any ideas why I am getting
> > when
> > I have the correct reference in the c# .net project?
> >
> > --
> > Cheers
> >
> > Ollie Riches
> > http://www.phoneanalyser.net
> >
> > Disclaimer: Opinions expressed in this forum are my own, and not
> > representative of my employer.
> > I do not answer questions on behalf of my employer. I'm just a
programmer
> > helping programmers.
> >
> >
>

File or assembly name Interop.DTS, or one of its dependencies, was not found.

I am trying to execute a DTS via COM according to the KB article
http://support.microsoft.com/?kbid=321525
but I am getting the exception "File or assembly name Interop.DTS, or one of
its dependencies, was not found." which is obviously a file not found
exception. I have sql server 2000 installed locally and I can run the
package from enterprise manager. Anyone got any ideas why I am getting when
I have the correct reference in the c# .net project?
Cheers
Ollie Riches
http://www.phoneanalyser.net
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.Is the Interop.DTS.dll in your application bin folder? This should get
generated when you build your project.
You might also check out the examples at
http://sqldev.net/dts/ExecutePackage.htm
Hope this helps.
Dan Guzman
SQL Server MVP
"Ollie Riches" <ollie.riches@.phoneanalser.net> wrote in message
news:OLP4UckJFHA.588@.TK2MSFTNGP15.phx.gbl...
>I am trying to execute a DTS via COM according to the KB article
> http://support.microsoft.com/?kbid=321525
> but I am getting the exception "File or assembly name Interop.DTS, or one
> of
> its dependencies, was not found." which is obviously a file not found
> exception. I have sql server 2000 installed locally and I can run the
> package from enterprise manager. Anyone got any ideas why I am getting
> when
> I have the correct reference in the c# .net project?
> --
> Cheers
> Ollie Riches
> http://www.phoneanalyser.net
> Disclaimer: Opinions expressed in this forum are my own, and not
> representative of my employer.
> I do not answer questions on behalf of my employer. I'm just a programmer
> helping programmers.
>|||yeap it was noob error, no dll in the bin directory
Ollie
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:#$jJFpkJFHA.2136@.TK2MSFTNGP14.phx.gbl...
> Is the Interop.DTS.dll in your application bin folder? This should get
> generated when you build your project.
> You might also check out the examples at
> http://sqldev.net/dts/ExecutePackage.htm
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Ollie Riches" <ollie.riches@.phoneanalser.net> wrote in message
> news:OLP4UckJFHA.588@.TK2MSFTNGP15.phx.gbl...
one[vbcol=seagreen]
programmer[vbcol=seagreen]
>

File or assembly name Interop.DTS, or one of its dependencies, was not found.

I am trying to execute a DTS via COM according to the KB article
http://support.microsoft.com/?kbid=321525
but I am getting the exception "File or assembly name Interop.DTS, or one of
its dependencies, was not found." which is obviously a file not found
exception. I have sql server 2000 installed locally and I can run the
package from enterprise manager. Anyone got any ideas why I am getting when
I have the correct reference in the c# .net project?
Cheers
Ollie Riches
http://www.phoneanalyser.net
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.Is the Interop.DTS.dll in your application bin folder? This should get
generated when you build your project.
You might also check out the examples at
http://sqldev.net/dts/ExecutePackage.htm
Hope this helps.
Dan Guzman
SQL Server MVP
"Ollie Riches" <ollie.riches@.phoneanalser.net> wrote in message
news:OLP4UckJFHA.588@.TK2MSFTNGP15.phx.gbl...
>I am trying to execute a DTS via COM according to the KB article
> http://support.microsoft.com/?kbid=321525
> but I am getting the exception "File or assembly name Interop.DTS, or one
> of
> its dependencies, was not found." which is obviously a file not found
> exception. I have sql server 2000 installed locally and I can run the
> package from enterprise manager. Anyone got any ideas why I am getting
> when
> I have the correct reference in the c# .net project?
> --
> Cheers
> Ollie Riches
> http://www.phoneanalyser.net
> Disclaimer: Opinions expressed in this forum are my own, and not
> representative of my employer.
> I do not answer questions on behalf of my employer. I'm just a programmer
> helping programmers.
>|||yeap it was noob error, no dll in the bin directory :)
Ollie
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:#$jJFpkJFHA.2136@.TK2MSFTNGP14.phx.gbl...
> Is the Interop.DTS.dll in your application bin folder? This should get
> generated when you build your project.
> You might also check out the examples at
> http://sqldev.net/dts/ExecutePackage.htm
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Ollie Riches" <ollie.riches@.phoneanalser.net> wrote in message
> news:OLP4UckJFHA.588@.TK2MSFTNGP15.phx.gbl...
one
programmer
>

File or assembly name Interop.DTS, or one of its dependencies, was not found.

I am trying to execute a DTS via COM according to the KB article
http://support.microsoft.com/?kbid=321525
but I am getting the exception "File or assembly name Interop.DTS, or one of
its dependencies, was not found." which is obviously a file not found
exception. I have sql server 2000 installed locally and I can run the
package from enterprise manager. Anyone got any ideas why I am getting when
I have the correct reference in the c# .net project?
Cheers
Ollie Riches
http://www.phoneanalyser.net
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.
Is the Interop.DTS.dll in your application bin folder? This should get
generated when you build your project.
You might also check out the examples at
http://sqldev.net/dts/ExecutePackage.htm
Hope this helps.
Dan Guzman
SQL Server MVP
"Ollie Riches" <ollie.riches@.phoneanalser.net> wrote in message
news:OLP4UckJFHA.588@.TK2MSFTNGP15.phx.gbl...
>I am trying to execute a DTS via COM according to the KB article
> http://support.microsoft.com/?kbid=321525
> but I am getting the exception "File or assembly name Interop.DTS, or one
> of
> its dependencies, was not found." which is obviously a file not found
> exception. I have sql server 2000 installed locally and I can run the
> package from enterprise manager. Anyone got any ideas why I am getting
> when
> I have the correct reference in the c# .net project?
> --
> Cheers
> Ollie Riches
> http://www.phoneanalyser.net
> Disclaimer: Opinions expressed in this forum are my own, and not
> representative of my employer.
> I do not answer questions on behalf of my employer. I'm just a programmer
> helping programmers.
>
|||yeap it was noob error, no dll in the bin directory
Ollie
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:#$jJFpkJFHA.2136@.TK2MSFTNGP14.phx.gbl...[vbcol=seagreen]
> Is the Interop.DTS.dll in your application bin folder? This should get
> generated when you build your project.
> You might also check out the examples at
> http://sqldev.net/dts/ExecutePackage.htm
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Ollie Riches" <ollie.riches@.phoneanalser.net> wrote in message
> news:OLP4UckJFHA.588@.TK2MSFTNGP15.phx.gbl...
one[vbcol=seagreen]
programmer
>

File IO Exception thrown when trying to access a CLR Assembly in SQL Server

I have been encountering a problem using a CLR Assembly in SQL server. The Assembly is one provided by Microsoft for an example on using Exchange web services with SQL server.

http://www.microsoft.com/downloads/details.aspx?FamilyId=D6924897-7B62-46FD-874E-24FB0FBA2159&displaylang=en#Requirements

Essentially what this package is, is a set of c# classes that access the Exchange 2007 Web Services via a set of user defined functions and views in MS SQL Server 2005.

We have not modified the code except to configure for our host environment.

We are able to register the assembly using the setup.sql file included. But when we try to access any of the views or use the functions we get the following error:

Msg 10314, Level 16, State 11, Line 10

An error occurred in the Microsoft .NET Framework while trying to load assembly id 65551. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error:

System.IO.FileLoadException: Could not load file or assembly 'exchangeudfs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=777b97dde00f3dbe' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

System.IO.FileLoadException:

at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)

at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)

at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)

at System.Reflection.Assembly.Load(String assemblyString)

We have 3 testing environments. 2 Windows 2003 servers called test and test2. Also a single Windows 2000 server called test3. Test and test2 have a full suite installed on them, web server, exchange 2007, sql server 2005, they are also domain controllers for their own domains.

We get the above error on test and test2 but it runs fine on test3. Test and test2 represent what our production environment is like. Test3 was just part of our troubleshooting process.

We have tried a lot to make this work. Here are some details on the things we have tried.

The database is set up to allow CLR Assemblies. This is part of the setup.sql.

The assembly's permission is set to external_access.

We have gone all the way to setting the file permissions on the dll to full control to the Everyone group.

We have tried different accounts to run the SQL Service. We've tried the system account, the local admin account and a seperate user account.

The database we are using is a fresh brand new database. Therefore it does not fit into the bug reported in this article:

http://support.microsoft.com/kb/918040

I am really at a loss to where to go from here. Any ideas on why this 'out of the box' solution is causing us so many headaches would be appriciated.

Thanks,

Tim

Which box did you compile your changes on? Do the full assembly identities match for the exchangeudfs assembly and all the dependents?

|||

I compiled the assembly on another seperate development machine. I'm not sure I know how to answer your second question.

|||

Fro whatever reason I recompiled it and it magically started working. Not sure why.

Sunday, February 19, 2012

File IO Exception thrown when trying to access a CLR Assembly in SQL Server

I have been encountering a problem using a CLR Assembly in SQL server. The Assembly is one provided by Microsoft for an example on using Exchange web services with SQL server.

http://www.microsoft.com/downloads/details.aspx?FamilyId=D6924897-7B62-46FD-874E-24FB0FBA2159&displaylang=en#Requirements

Essentially what this package is, is a set of c# classes that access the Exchange 2007 Web Services via a set of user defined functions and views in MS SQL Server 2005.

We have not modified the code except to configure for our host environment.

We are able to register the assembly using the setup.sql file included. But when we try to access any of the views or use the functions we get the following error:

Msg 10314, Level 16, State 11, Line 10

An error occurred in the Microsoft .NET Framework while trying to load assembly id 65551. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error:

System.IO.FileLoadException: Could not load file or assembly 'exchangeudfs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=777b97dde00f3dbe' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

System.IO.FileLoadException:

at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)

at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)

at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)

at System.Reflection.Assembly.Load(String assemblyString)

We have 3 testing environments. 2 Windows 2003 servers called test and test2. Also a single Windows 2000 server called test3. Test and test2 have a full suite installed on them, web server, exchange 2007, sql server 2005, they are also domain controllers for their own domains.

We get the above error on test and test2 but it runs fine on test3. Test and test2 represent what our production environment is like. Test3 was just part of our troubleshooting process.

We have tried a lot to make this work. Here are some details on the things we have tried.

The database is set up to allow CLR Assemblies. This is part of the setup.sql.

The assembly's permission is set to external_access.

We have gone all the way to setting the file permissions on the dll to full control to the Everyone group.

We have tried different accounts to run the SQL Service. We've tried the system account, the local admin account and a seperate user account.

The database we are using is a fresh brand new database. Therefore it does not fit into the bug reported in this article:

http://support.microsoft.com/kb/918040

I am really at a loss to where to go from here. Any ideas on why this 'out of the box' solution is causing us so many headaches would be appriciated.

Thanks,

Tim

Which box did you compile your changes on? Do the full assembly identities match for the exchangeudfs assembly and all the dependents?

|||

I compiled the assembly on another seperate development machine. I'm not sure I know how to answer your second question.

|||

Fro whatever reason I recompiled it and it magically started working. Not sure why.