Csla for Silverlight, C++ Libraries, and the AppDomain

Csla for Silverlight, C++ Libraries, and the AppDomain

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


Patrick.Roeper posted on Wednesday, February 24, 2010

I was running into an exception today...

System.TypeInitializationException: The type initializer for 'Atalasoft.Imaging.AtalaImage' threw an exception. ---> System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> <CrtImplementationDetails>.ModuleLoadException: The C++ module failed to load while attempting to initialize the default appdomain.
---> System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Csla.Security.UnauthenticatedPrincipal,Csla, Version=3.8.1.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30'.
at System.AppDomain.get_Id()
at <CrtImplementationDetails>.DoCallBackInDefaultDomain(IntPtr function, Void* cookie)
at <CrtImplementationDetails>.DefaultDomain.Initialize()
at <CrtImplementationDetails>.LanguageSupport.InitializeDefaultAppDomain(LanguageSupport* )
at <CrtImplementationDetails>.LanguageSupport._Initialize(LanguageSupport* )
at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* )
--- End of inner exception stack trace ---
at <CrtImplementationDetails>.ThrowModuleLoadException(String errorMessage, Exception innerException)
at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* )
at .cctor()
--- End of inner exception stack trace ---
at a(String , Exception )
at c(atalano* )
at .cctor()
--- End of inner exception stack trace ---
at Atalasoft.Imaging.AtalaImage..cctor()
--- End of inner exception stack trace ---
(my code here)

... and I was trying to figure out what was going on. Atalasoft is a component vendor that is popular in the .NET space for imaging components, and it just so happens that we use them for imaging features in our software. I started getting this exception whenever the silverlight client issued a dataportal request that, when on the server, hit an aspect of Atalasoft.

I came across this post from the past: http://forums.lhotka.net/forums/p/4366/21404.aspx#21404 Pretty similar right? The difference here is that I know Atalasoft will work in an ASP.NET environment.

Long story short, I found that if I ran some Atalasoft code from the global.asax during application start, the dlls would spin up just fine, and I would no longer get the above exception when hitting Atalasoft during a dataportal request.

So the question is, what is it about the wcf dataportal that prevents this component vendor's libraries from loading into ASP.NET? I'm really not sure where to start digging here.

RockfordLhotka replied on Wednesday, February 24, 2010

One thing to consider is that WCF doesn't use the page lifecycle you get with an ASP.NET Web Form. Some parts of the lifecycle are similar, but most of the page lifecycle doesn't apply to services, and so doesn't occur in a WCF service call.

Or to put it another way, ASP.NET is a base platform on which you now find Web Forms, MVC and WCF. The sequence of events that occurs when an inbound request comes into each of these three technologies is different. Just because a component works in Web Forms doesn't mean it will work in the other two.

Copyright (c) Marimer LLC