Could not load file or Assembly issue

Could not load file or Assembly issue

Old forum URL: forums.lhotka.net/forums/t/8600.aspx


ninoarena posted on Tuesday, March 02, 2010

I am getting this error on InitializeComponent of my XAML code behind that has the CslaDataProvider.   I think I check everything and can't seem to figure out what could be causing this issue.

Environment:   CSLA 3.8.2.0 (Both light and Core),  Windows 7 Ultimate, VS 2010 Beta version,  .NET 3.5, Silverlight 3

Thanks.

bniemyjski replied on Wednesday, March 03, 2010

Hello,

Can you please provide a full stack trace for this error, also if you could attach a screen shot of your project references that would be great.

Thanks

-Blake Niemyjski

ninoarena replied on Wednesday, March 03, 2010

Thanks for the prompt reply.

I'll provide the stack and the screen shot as soon as I find how to post a screen shot in this forum.  I have the simplest one table and one column that I am trying to retrieve and show in a Silverlight screen using CSLA.   Our company is moving to use Silverlight and convincing them to use CSLA.  However, I find that nothing seems to work for me.  I followed the video and the Rolodex sample.  What I did basically is build a Silverlight Navigation Application then created my business objects, one inherited from ‘ReadOnlyListBase’ and the child from ‘ReadOnlyBase’.  Proceeded to create the client side of the business objects using the Add link under a Silverlight Class library.  Then on my XAML, use the csladataprovider.  When I was debugging it, the reflection gettype is failing to load the assembly. 

cogaivotchong replied on Wednesday, March 03, 2010

Our company is moving to use Silverlight and convincing them to use CSLA. However, I find that nothing seems to work for me.


epabx system
commercial telephone systems
telephone system installation

bniemyjski replied on Wednesday, March 03, 2010

Hello,

If you can provide a sample solution that isn't working for you that works the best. Then we can debug it on our end and get it resolved for you guys. The quickest fix without taking a look at the references or stack trace would be to make sure that the CSLA assembly or the assembly in question is in the GAC (Gacutil -i csla.dll) as well as bin folder of your application. If you are still having issues, one of the quick fixes would be to tie into the AppDomain.AssemblyResolve event.

Thanks

-Blake Niemyjski

ninoarena replied on Thursday, March 04, 2010

Hi,

Thanks for the offer.  How can I can send a sample solution?  

Let me know.

Thanks again.

RockfordLhotka replied on Wednesday, March 03, 2010

ninoarena

When I was debugging it, the reflection gettype is failing to load the assembly. 

What is the type name you are providing to the CslaDataProvider? It must be in the form "Namespace.Class, Assembly" or it won't work. The most common issues are missing the assembly name or mis-typing the namespace.

Of course the Silverlight application must reference the business project so the business DLL is included in the xap file - otherwise the type won't exist on the client at all.

ninoarena replied on Thursday, March 04, 2010

The type name I am providing is correct.  However I noticed that the version number in the error message is 0.0.0.0 not the 1.0.0.0 I was expecting.   Could that be a clue to the issue?

Thanks.

bniemyjski replied on Thursday, March 04, 2010

Hello,

That could be the issue, can you please paste the type name you are passing in. You can attach a solution by logging into the forum and selecting add a file attachment in the options tab when you are writing a message.

Thanks

-Blake Niemyjski

RockfordLhotka replied on Thursday, March 04, 2010

ninoarena

The type name I am providing is correct.  However I noticed that the version number in the error message is 0.0.0.0 not the 1.0.0.0 I was expecting.   Could that be a clue to the issue?

The Silverlight Type.GetType() method doesn't work the same as the .NET one - in particular it can't actually handle type names like "Namespace.Type, Assembly". It specifically requires the version, culture and other long-form parts of the type name - again, unlike .NET.

So CSLA .NET for Silverlight helps solve the simple case, by detecting the short-form name and appending the most common (neutral) version/culture/etc. If you aren't explicitly signing or versioning your assemblies this works great.

Of course if you sign or version your assemblies then you need to provide the full type name with all the explicit information, because Silverlight doesn't offer any way to auto-detect that information.

ninoarena replied on Friday, March 05, 2010

Hi,

I finally got it to work on my MS Sql Server and the reason for the initial failure is my failure to reference the Silverlight business class library in the Silverlight Client as pointed out by Rocky. 

Thank you so much as this brought back confidence on our pursuit to have our first CSLA and Silverlight project.

However, now that it I have proven that it works on my personal laptop using MS SQL Server,  I now have to move it to our Sybase database environment at work.  When I did this and made all the necessary changes for the database connection.  I start getting the following error. 

I wish I can get the this to work too. 

Thanks again to both Rocky and Blake.

"An exception occured during the operation, making the result invalid. Check InnerException for exception details. "

When I tried to view my svc file in the browser to test,  I get the following error instead of the usual message.

 

 

Server Error in '/' Application.

 


 

Could not load file or assembly 'CQLA' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Description:

An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'CQLA' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Source Error:

 

 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

[FileLoadException: Could not load file or assembly 'CQLA' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
   System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43
   System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127
   System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46

[ConfigurationErrorsException: Could not load file or assembly 'CQLA' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +613
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
   System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +163
   System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +53
   System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +175
   System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +83
   System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +261
   System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +101
   System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +83
   System.Web.Compilation.BuildManager.GetCompiledCustomString(String virtualPath) +27
   System.ServiceModel.HostingManager.GetCompiledCustomString(String normalizedVirtualPath) +134
   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +23
   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +42
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +479

[ServiceActivationException: The service '/WcfPortal.svc' cannot be activated due to an exception during compilation.  The exception message is: Could not load file or assembly 'CQLA' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).]
   System.ServiceModel.AsyncResult.End(IAsyncResult result) +11527290
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +194
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +176
   System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +278
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

ajj3085 replied on Friday, March 05, 2010

What is Cqla?  Looks like a typo...

ninoarena replied on Friday, March 05, 2010

I searched everywhere and can't find that CQLA word either.  My first thought exactly that at first, that it's a typo but it doesn't seems to be.

RockfordLhotka replied on Friday, March 05, 2010

  1. Open your solution
  2. Do a Ctrl-Shift-F to bring up the global file search dialog
  3. Type cqla into the search term box
  4. Make sure the Entire Solution is selected for search scope
  5. Do the search

From the exception, it looks like the typo is in your WCF svc file or web.config, but the global file search will find it for you.

ninoarena replied on Friday, March 05, 2010

Hi Rocky,

I did a global file search as you suggested and the search did not find anything that has the word cqla.   This application works in MS Sql Server which makes me think that the WCF svc file or web.config is unchanged besides the connection string.  The error I encounter when running the application is

"An exception occured during the operation, making the result invalid. Check InnerException for exception details. "  

In debugging this, the application does NOT reach the business object server side DataPortal_Fetch().  I'll try to step in deeper into the debugger but appreciate any tip or suggestions.

Thanks,

Nino

ninoarena replied on Saturday, March 06, 2010

Hi,

I finally got this thing working.  Appreciate all the replies.  Those replies showed me places to look at which resulted well.

In short, the solution I found on my Sybase environment is to remove the wcf host and move the svc file in the web host.  I think the cross domain is what's causing all the issue.  I am guessing of course but at this point, all I wanted is to have some success to convince my group to move forward on our CSLA and Silverlight project.

Thank you so much!!!

Nino

ajj3085 replied on Wednesday, March 03, 2010

Besides giving the detail Blake requested, I think the recommendation is to no longer use CslaDataProvider but instead go the MVVM route.  That component will be removed I believe just after Csla 4.0.

Copyright (c) Marimer LLC