This project has moved. For the latest updates, please go here.

The C++ module failed to load while attempting to initialize the default appdomain

Jul 9, 2015 at 7:19 AM
Edited Jul 9, 2015 at 7:26 AM

The magick.net is working fine with AnyCpu.dll on local machine, but when I uploaded the build to my server which is x64 and included AnyCPU.dll I start getting the following error.

<b>InnerException :</b><CrtImplementationDetails>.ModuleLoadException: The C++ module failed to load while attempting to initialize the default appdomain.
---> System.Runtime.Serialization.SerializationException: Type 'ss.Web.UI.CustomTicket' in Assembly 'ss, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

Server stack trace:
at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type)
at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
at System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage..ctor(IMethodCallMessage mcm)
at System.Runtime.Remoting.Channels.CrossAppDomainSink.SyncProcessMessage(IMessage reqMsg)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.AppDomain.get_Id()
at <CrtImplementationDetails>.DoCallBackInDefaultDomain(IntPtr function, Void* cookie)
at <CrtImplementationDetails>.LanguageSupport._Initialize(LanguageSupport* )
at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* )
--- End of inner exception stack trace ---
at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* )
at .cctor()<br /><b>Source : </b>Magick.NET-AnyCPU<br /><b>Trace : </b> at ImageMagick.MagickImage..ctor()
at ImageMagick.MagickImage..ctor(String fileName)

at SyndicationController.Edit()<br /><b>Other Info : </b><br /><br /><b>Raw U R L : </b>/Syndication/Edit/1017<br /><b>URL : </b>ss.testsep.com/Syndication/Edit/1017<br /><b>

ALSO IN Windows log I got following error :

Exception: System.Runtime.Serialization.SerializationException

Message: Unable to find assembly 'Magick.NET.Wrapper-x64, Version=7.0.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec'.

What will be the possible solution for same?
Thanks in advance...
Coordinator
Jul 9, 2015 at 8:39 PM
Do you see any files in the following folder: %TEMP%\Magick.NET.7.0.0.0015. It might be possible that your process cannot access the temp folder on your server. You change the cache folder for the AnyCPU version with the CacheDirectory property of the MagickAnyCPU class.
Jul 30, 2015 at 6:12 AM
Edited Jul 30, 2015 at 6:12 AM
Thanks, It is working now. But I have to use wrapper class also in my AnyCPU build.

Also I need help with converting psd from other source using http path. Is there any sample code/doc for same??

Awaiting reply...

Thanks & Regards.
Coordinator
Jul 30, 2015 at 10:50 AM
MagickImage has a constructor that accepts a Stream. You can obtain a stream with the help of the WebRequest class in .NET
Aug 14, 2015 at 6:36 AM
Edited Aug 14, 2015 at 6:37 AM
Question : Does magic.net read whole file To Convert PSD, TIF file into jpeg format ?
Coordinator
Aug 14, 2015 at 6:47 AM
I am not sure how your question is related to this topic. When you convert one image to another format the whole source image is read to create the destination image.
Aug 14, 2015 at 6:58 AM
Edited Aug 14, 2015 at 6:58 AM
suppose i want to extract first layer/image from PSD and TIF file into image ,then what would be the read process of magic.net.
Feb 4, 2016 at 5:18 AM
Edited Feb 4, 2016 at 5:37 AM
Hi,

I have uploaded web app to new server including Magick.NET-7.0.0.0022-Q16-x64 - net40-client (Magick.NET.Core , Magick.NET.Wrapper-x64 , Magick.NET-x64) . but it is giving error on server :

Could not load file or assembly 'Magick.NET.Wrapper-x64.DLL' or one of its dependencies. The specified module could not be found.

Server Error in '/' Application.

Could not load file or assembly 'Magick.NET.Wrapper-x64.DLL' or one of its dependencies. The specified module could not be found.

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.FileNotFoundException: Could not load file or assembly 'Magick.NET.Wrapper-x64.DLL' or one of its dependencies. The specified module could not be found.

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.

Stack Trace:


[FileNotFoundException: Could not load file or assembly 'Magick.NET.Wrapper-x64.DLL' or one of its dependencies. The specified module could not be found.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +210
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +242
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +17
System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +122

[ConfigurationErrorsException: Could not load file or assembly 'Magick.NET.Wrapper-x64.DLL' or one of its dependencies. The specified module could not be found.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +12497268
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +499
System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +131
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +331
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +148
System.Web.Compilation.BuildManager.ExecutePreAppStart() +172
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151

[HttpException (0x80004005): Could not load file or assembly 'Magick.NET.Wrapper-x64.DLL' or one of its dependencies. The specified module could not be found.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12618980
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12458597

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34274

Can you please help me with the issue I am facing....

Awaiting reply...

Thanks in Advance.
Coordinator
Feb 4, 2016 at 7:00 AM
Did you install the C++ Redistributable?
Feb 4, 2016 at 10:57 AM
Hi,

Yes it is installed on server..

When I include wrapper on server, then it does not allow application to run even. Gives yellow screen error :
Could not load file or assembly 'Magick.NET.Wrapper-x64.DLL' or one of its dependencies. The specified module could not be found.

and when I do not include wrapper then application runs. but the line where i obect creates "using (MagickImage imageConvert = new MagickImage(path))"
it again gives error :
"System.IO.FileNotFoundException: Could not load file or assembly 'Magick.NET.Wrapper-x64, Version=7.0.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec' or one of its dependencies. The system cannot find the file specified.

Please help to resolve issue...

Thanks,
Coordinator
Feb 4, 2016 at 7:45 PM
That does sound like a C++ Redistributable error. Can you try it with the latest version of Magick.NET? Version 7.0.0.0101 no longer requires the C++ Redistributable.
Feb 5, 2016 at 5:07 AM
Thank you for the update but I am not able to add refrence of native.dll
getting following error :

A reference to 'D:\Rob\Projects\PSDtoIMG_Preview\Magick.NET-7.0.0.0101-Q16-x86\net20\Magick.NET\Magick.NET-Q16-x86.Native.dll' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.
Coordinator
Feb 5, 2016 at 6:56 AM
You are not able to add a reference to that dll because you shouldn't :) Its a native library that is executed from the Magick.NET library. You only need to make sure that it is in your 'bin' folder.
Feb 5, 2016 at 7:09 AM
Hey thanks a ton. I used AnyCpu and now it is working like a charm... Thanks a lot :)