Thursday, May 29, 2008

Error : The assembly could not be found at or could not be loaded

I have an excel application created using .Net framework 1.1 and Microsoft Office Excel 2003. This application named CBlotter with the same settings and dll in all the user computers was running fine but only in 1 computer , I encountered the error saying "The assembly CBlotter could not be found at .\CBlotter_bin\ or could not be loaded. You can still edit and save the document.Contact your administrator or the author of this document for further assistance." I checked all the user permissioning of the folder. I gave the full trust policy if not already given to the folder by using Caspol.exe(Code Access Security Policy Tool). This can be done by going to the specified v1.1/v2.0 folder. If you want to grant full trust to a local folder , then type caspol -u -ag All_Code -url C:\\\* FullTrust -n "" -d "" If you want to grant full trust to a netwrok folder , then type caspol -pp off -m -ag LocalIntranet_Zone -url \\\\* FullTrust -n "" -d "" After assigning the right permissioning and full trust , usually the assembly loading/cannot find error goes away but in my case it dint. So Now, I checked for the assemblies required for my .net code to run . In VS2003 we add reference to the COM library called 'Microsoft Excel 11.0 Object Library'. This helps us use the Excel Objects and write our piece of code using VS2003. When I checked the library in assembly cache (GAC), using microsoft 1.1 configuration GUI, I was not able to locate the assembly. This actually raised a question as Microsoft Office Excel 2003 and .Net 1.1 framework was completely installed on User's PC then why were the Primary Interop Libraries (PIA) missing. After researching I found out that these libraries require re-registration or installation sometimes when some other office application initiates a setup that causes library registration to be rewritten. In my case Microsoft Excel SP3 installation had removed the PIAs altogether . So I just installed the PIAs again by going to the site This solved my problem.

1 comment:

Anonymous said...

Thanks a lot. It was very informative. It solved my problem. Kudos!!!!