The type initializer for 'Aspose.CAD.Image' threw an exception

Suddenly, after long time of using the Aspose.CAD it is not working on the production server
In dev it works, on the server, where I can’t use debug methods it throw exception: The type initializer for ‘Aspose.CAD.Image’ threw an exception.

version 23.9

@yoniDekel,
Hi.
We observed such error earlier and the reason was access rights to C:\WINDOWS\TEMP\TempFonts folder that is used to work with fonts. Please, give rights to application to access it.

What is the best thing to try:
Iis user full access
Everyone full access because it is only font folder
Any thing else?

1510_5331186793_mail_8d1710fb-bcb2-4aa4-8669-2a728f87ca77.jpg (56.8 KB)

asset20_ce831691-7af1-4a28-8578-d1a350867362.png (2.29 KB)

whatsapp_logo_1-removebg-preview1_e8eb4d73-5f73-4224-89a9-ca4c8a1755de.png (15 KB)

i don’t see i have this folder you mentioned
why? and should i create it on my own?

@yoniDekel,
I believe it is not required to create some folder manually, we will check it and I will provide additional info on this. It could be helpful if you can provide more details of the exception, because the source of the issue could be different too. Is it appear at load or at save of the drawing? What led to this behavior, some changes, update of the version? Did expanding access rights help? It this behavior the same for other Aspose.CAD version? Are the environments the same for both servers? Is it possible to create some short demo example that we can run and analyze?

I’m using the load only, in order to get number of pages and their width/height

I have been using version 23.6
And it happens with no known reason
I have tried 23.9 and same behavior

I did not expanded the access right because as i have said, i don’t have the folder you mentioned

On dev local it works but not in prod. They are not the same

I just load file from location in the server

1510_5331186793_mail_8d1710fb-bcb2-4aa4-8669-2a728f87ca77.jpg (56.8 KB)

asset20_ce831691-7af1-4a28-8578-d1a350867362.png (2.29 KB)

whatsapp_logo_1-removebg-preview1_e8eb4d73-5f73-4224-89a9-ca4c8a1755de.png (15 KB)

@yoniDekel,
OK, now it seems not related to fonts (because that issue has been occurring at export). Can you print the entire stack trace of this exception?

in- Dekel.PrintOrder.GetFileData_Data.ProcessRequest(HttpContext context) in- System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() in- System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) in- System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) in- System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error) in- System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb) in- System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) in- System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) in- System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) in- System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus) in- System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus) in- System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) in- System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)

@yoniDekel.
please, try to increase access rights for C and verify if this fixes the issue or not.

You mean access to drive c?

1510_5331186793_mail_8d1710fb-bcb2-4aa4-8669-2a728f87ca77.jpg (56.8 KB)

asset20_ce831691-7af1-4a28-8578-d1a350867362.png (2.29 KB)

whatsapp_logo_1-removebg-preview1_e8eb4d73-5f73-4224-89a9-ca4c8a1755de.png (15 KB)

1 Like

@yoniDekel,
yes.

But why? What changed?
If i will give entire drive c permission to what user?

1510_5331186793_mail_8d1710fb-bcb2-4aa4-8669-2a728f87ca77.jpg (56.8 KB)

asset20_ce831691-7af1-4a28-8578-d1a350867362.png (2.29 KB)

whatsapp_logo_1-removebg-preview1_e8eb4d73-5f73-4224-89a9-ca4c8a1755de.png (15 KB)

@yoniDekel,
We believe we changed nothing that may lead to this case. As we understood the same Aspose.CAD version works fine for you on one server but failed on other. We propose you to give a try with extending rights (for C, for C:\Windows or C:\Windows\Temp) for the user running the app searching for the possible way to fix the issue. Please, provide the stack trace related to Aspose.CAD classes, so we can identify the source of the error, or create some simple sample app we can use to reproduce the issue.

I did not say it works on another server. I have said it works locally on dev computer there for sending you code for loading a dwf code wont work

I did not change anything on the server between the time it worked and when it stopped even not the aspose cad version

How do i get the stack trace for aspose?

1510_5331186793_mail_8d1710fb-bcb2-4aa4-8669-2a728f87ca77.jpg (56.8 KB)

asset20_ce831691-7af1-4a28-8578-d1a350867362.png (2.29 KB)

whatsapp_logo_1-removebg-preview1_e8eb4d73-5f73-4224-89a9-ca4c8a1755de.png (15 KB)

Adding permissions to windows temp did not do anything, even to entite Everyone

Tried that with drive C as well - nothing

1510_5331186793_mail.jpg

image001.png (755 Bytes)

asset20_ce831691-7af1-4a28-8578-d1a350867362.png (2.29 KB)

whatsapp_logo_1-removebg-preview1_e8eb4d73-5f73-4224-89a9-ca4c8a1755de.png (15 KB)

@yoniDekel,
“The type initializer for ‘Aspose.CAD.Image’ threw an exception.” this is the begin of exception message, please, print message, stack trace, inner exception for this exception, or any other information about Aspose.CAD classes if you can see it, so we can find the source of the error.

Can this help?

System.TypeInitializationException: The type initializer for ‘Aspose.CAD.Image’ threw an exception. —> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) at System.Reflection.Assembly.GetTypes() at Aspose.CAD.Image…cctor() — End of inner exception stack trace — at Aspose.CAD. Image.Load(String filePath) at Dekel.PrintOrder.GetFileData_Data.ProcessRequest(HttpContext context)

1510_5331186793_mail.jpg

image001.png (755 Bytes)

asset20_ce831691-7af1-4a28-8578-d1a350867362.png (2.29 KB)

whatsapp_logo_1-removebg-preview1_e8eb4d73-5f73-4224-89a9-ca4c8a1755de.png (15 KB)

@yoniDekel,
yes, this is helpful, now we can guess (because saw this previously) that some required libraries are missing (probably System.Memory 4.0.1.1 and/or System.Text.Json 6.0.0.0). Please print the LoaderExceptions property from the exception, it should be mentioned there directly. What is the version of .NET we are talking about?

I’m unable to get that for you

No meter what I try in order to print LoaderExceptions it is either null or if I configure catch for it, it won’t get there

Any ideas? Can we do a zoom session maybe?

1510_5331186793_mail.jpg

image001.png (755 Bytes)

asset20_ce831691-7af1-4a28-8578-d1a350867362.png (2.29 KB)

whatsapp_logo_1-removebg-preview1_e8eb4d73-5f73-4224-89a9-ca4c8a1755de.png (15 KB)

@yoniDekel,
without knowing values from LoaderException we can only guess what errors occur for what libraries, as the problem may occur for one library or for muiltiple. Can you check what versions of the System.Memory and System.Text.Json are available to refer for your project type on the server? Can you try to install these libraries from NuGet for your project and check if it changes something?