Unable to get ImageMagick .Net working with Asp.Net 4.0 - image-processing

I have downloaded the ImageMagick.Net source code from Codeplex and compiled using Visual Studio 2010. It builds but when I use the generated ImageMagickNET.dll into my Asp.Net 4.0 application I get the following error.
External component has thrown an exception.
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.Runtime.InteropServices.SEHException: External component has thrown an exception.
Source Error:
Line 1049: void Image::Read(System::String^ imageSpec)
Line 1050: {
Line 1051: image->read(Marshaller::SystemStringToStdString(imageSpec));
Line 1052: }
Line 1053:
Source File: d:\dev\projects\imagemagick-63489\imagemagick.net\imagemagicknet\image.cpp Line: 1051
Stack Trace:
[SEHException (0x80004005): External component has thrown an exception.]
Magick.Image.read(Image* , basic_string<char\,std::char_traits<char>\,std::allocator<char> >* ) +0
ImageMagickNET.Image.Read(String imageSpec_) in d:\dev\projects\imagemagick-63489\imagemagick.net\imagemagicknet\image.cpp:1051
ImageMagickTest._Default.Page_Load(Object sender, EventArgs e) in D:\Sites\ImageMagickTest\ImageMagickTest\Default.aspx.cs:22
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
Has anyone got ImagMagick.Net working by compiling from the source code?

I know this is a bit of an old question, but this looks similar to an issue with unmatched ImageMagick versions that I was seeing.
If you are using the ImageMagickNET from their sources, you need to make sure you have ImageMagick 6.5.3-10 installed. This probably means building that release from sources, as I don't think the binaries are available anywhere (at least for Windows).
If you updated the ImageMagickNET project with sources from a new ImageMagick release, then you can use it with your newer installed version of ImageMagick. However, I experience several crashes when trying this approach with ImageMagick 6.6.6-10 on Windows. It may be that too much has changed in the underlying library for the ImageMagickNET wrapper to work correctly with this more recent version.

Related

Xamarin Error XA0009 - Format of Executable or Library is invalid

I am struggling to make an Android App, but it always seems to end in this particular failure:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Exception while loading assemblies: Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA0009: Error while loading assembly: bin/Debug/(projectname).dll ---> System.BadImageFormatException: Format of the executable (.exe) or library (.dll) is invalid.
at Mono.Cecil.PE.ImageReader.ReadImage () [0x0002d] in <1b827dd2cbec4ef6829dffcefdcd3b01>:0
at Mono.Cecil.PE.ImageReader.ReadImage (Mono.Disposable1[T] stream, System.String file_name) [0x0000a] in <1b827dd2cbec4ef6829dffcefdcd3b01>:0
at Mono.Cecil.ModuleDefinition.ReadModule (Mono.Disposable1[T] stream, System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00007] in <1b827dd2cbec4ef6829dffcefdcd3b01>:0
at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00073] in <1b827dd2cbec4ef6829dffcefdcd3b01>:0
--- End of inner exception stack trace ---
at Java.Interop.Tools.Diagnostics.Diagnostic.Error (System.Int32 code, System.Exception innerException, System.String message, System.Object[] args) [0x0000a] in :0
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Load (System.String fileName) [0x00045] in <9ca47d05131d4b8c85910dacd818f0c6>:0
at Xamarin.Android.Tasks.ResolveAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver) [0x00123] in <3f37ea95794e430e91f10accab4cf241>:0 ((projectname))
I am wondering what on earth might be causing the error, as I have tried multiple solutions to avoid the error and it often turns up in such random ways.
Last time I got the error it occurred as follows:
I had a project with only two Activity-files and two Layout files.
I created a gridview in the other layout and tested it on the Android emulator -> all was working well.
I resized the gridview and tested the app with the emulator -> error mentioned above occurred.
I deleted the solution, restored a manual backup saved in an other location, and tested it -> it was working.
I repeated the procedure with the gridview -> error occurred.
Now, as I deleted the project and tried to restore the backup again, even the backup did not work anymore. I tried to build it, then clean it and build but every attempt to build it resulted now as an error.
I seem to get mystic errors from time to time ( like Emulator image stopped working after all I did was just add a button with the designer) but every time troubleshooting eventually comes down to this error and I have to scrap the project. I have been working with Xamarin now 18 hours this weekend and 4 hours have been coding and the rest trying to fix the never-ending errors.
I am using MacBook Pro and have tried running the solution from the default directory and external drive.
So in a nutshell: What causes the error mentioned above and can it be fixed or at least avoided?
I tried to google ( long and hard) but could not find a solution that would be of any help.
Ps. Sorry if the post was not correct, it is my first. Would not have posted in the first place but I am desperate.
Thank you for your patience to read all the way to here.

reactjs.net - 'potential stack overflow detected' error

Since I've decided to switch to server-side rendering from client-side react, I began to create my components and use them in the app.
However I came across this error:
Unknown error (RangeError); potential stack overflow detected
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: Microsoft.ClearScript.ScriptEngineException: Unknown error (RangeError); potential stack overflow detected
And this is a part from the stack-trace
[ScriptEngineException: Unknown error (RangeError); potential stack overflow detected]
V8Exception.ThrowScriptEngineException(V8Exception* ) +169
Microsoft.ClearScript.V8.V8ContextProxyImpl.Execute(String gcDocumentName, String gcCode, Boolean evaluate, Boolean discard) +462
Microsoft.ClearScript.V8.<>c__DisplayClass1b.<Execute>b__19() +197
Microsoft.ClearScript.ScriptEngine.ScriptInvoke(Func`1 func) +70
Microsoft.ClearScript.V8.V8ScriptEngine.BaseScriptInvoke(Func`1 func) +49
Microsoft.ClearScript.V8.<>c__DisplayClass25`1.<ScriptInvoke>b__24() +45
Microsoft.ClearScript.V8.?A0x792c8756.LockCallback(Void* pvArg) +9
Microsoft.ClearScript.V8.V8ContextProxyImpl.InvokeWithLock(Action gcAction) +176
Microsoft.ClearScript.V8.V8ScriptEngine.ScriptInvoke(Func`1 func) +118
Microsoft.ClearScript.V8.V8ScriptEngine.Execute(String documentName, String code, Boolean evaluate, Boolean discard) +118
JavaScriptEngineSwitcher.V8.V8JsEngine.InnerEvaluate(String expression) +89
So I don't know what causes this error but I think it is some code that goes in a loop or something similar. Furthermore if I refresh the page this error goes away and if I continue to refresh intensively it shows up again which is very frustrating.
I was getting the same error (web app in azure) and after some investigation and tests, setting SetAllowMsieEngine to true did in fact fixed the issue also to me.
As Luke McGregor said, this seems to be an issue with V8ScriptEngine and using SetAllowMsieEngine does the job, however this method is latest version of react.net is deprecated and is recommended to "managed in the JavaScriptEngineSwitcher configuration".
So the solution I found so far is to switch js engine switcher by setting it directly in code:
JsEngineSwitcher engineSwitcher = JsEngineSwitcher.Instance;
engineSwitcher.EngineFactories
.AddChakraCore()
.AddMsie( new MsieSettings() { EngineMode = JsEngineMode.Auto } );
engineSwitcher.DefaultEngineName = ChakraCoreJsEngine.EngineName;
Like this I'm using ChakraCore engine rather than default V8 which was causing the error.
So far, during our performance tests with around 250 concurrent requests, we do not have this error anymore when previously in the same conditions for sure this error would have occurred.
This is a known issue, see https://github.com/reactjs/React.NET/issues/190
The work around is to not use V8 to do the render ie:
app.UseReact(config =>
{
config
// ..other configuration settings
.SetAllowMsieEngine(true);
});

External component has thrown an exception after framework upgrade on server

I recently upgraded a 2008 R2 Web server to .Net Framework 4.6.1. I then installed my ASP.NET MVC application on such which is built to .Net Framework 4.6.1. When I attempt to run the site, I get the following error.
External component has thrown an exception.
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.Runtime.InteropServices.SEHException: External component has thrown an exception.
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:
[SEHException (0x80004005): External component has thrown an exception.]
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) +485
System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) +190
System.Reflection.Assembly.LoadFrom(String assemblyFile) +54
WebActivator.ActivationManager.get_Assemblies() +244
WebActivator.ActivationManager.RunActivationMethods() +86
WebActivator.ActivationManager.RunPreStartMethods() +46
WebActivator.ActivationManager.Run() +68
[InvalidOperationException: The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: External component has thrown an exception..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +900
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +164
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +169
System.Web.Compilation.BuildManager.ExecutePreAppStart() +172
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +907
[HttpException (0x80004005): The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: External component has thrown an exception..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +579
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +118
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +726
I did same process on other similar servers and didn't hit an issue.
I did find that in IIS (which the site is running in), if I change the application pools "Load User Profile" setting to false then the site runs without a problem.
I don't just want to change this setting (unsure of its impact on the application), I would like to understand why I need to make such a change on this server and didn't need to on others. Was it the way the framework was installed or server is setup? Any feedback would be great.
(note: the server has version 4.5 installed and the site when built in such, ran without an issue)
I ran in this problem once, on many cases problem is due to some software in the dev suite that was not up to date. In my case the problem was caused due to Telerik justMock, The problem was resolved by updating justmock to latest version. Try to update or uninstall Telerik tools if you have one, Hope this solves your problem
External component has thrown an exception.
I had before similar problem after installing .Net Framework 4.6.1 - I have not figured out what component cause problem, but problem was related to missing .NET Framework 4.5.1 Targeting Pack.
Solution in my case:
uninstall all .NET Frameworks,
install .NET Framework 4.5.1 Developer Pack
install .NET Framework 4.5.2 Developer Pack
install .NET Framework 4.6.1 Targeting Pack
(the order is important)
All downloaded form official site: Targeting .NET Platforms

Cannot Insert image through Umbraco RichText editor

The problem regarding richtext editor in Umbraco 4.
I am not able to add images through the RichText editor. When i click on the add image icon on the rich text editor, the popup panel displays an error (find in resource number 2).
The RichText editor datatype is using Tinymce3 as its type.
The resources ihave used and did not solve the problem.
1) http://our.umbraco.org/forum/using/ui-questions/39103-Problem-with-Rich-Text-Editor-and-Inserting-Images
2) Rich Text Editor and Inserting Images getting error
What i have done(they did not work):
a) resaved the RichText editor datatype with different Type,
b) deleted the RichText editor(bad mistake) and recreated it,
c) copied the code of insertimage.aspx from different projects wherever the RichText editor is working,
Kindly, have a look at the error image i have attached with this question.
Any suggestion would be helpful.
Error
Server Error in '/' Application.
Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
[No relevant source lines]
Source File: c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\1096afd0\6b67abfd\App_Web_uploadmediaimage.ascx.c3c18f9f.5y91thdt.0.cs Line: 0
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
umbraco.cms.businesslogic.datatype.DataTypeDefinition.b__0(DataTypeDefinition x) +235
System.Linq.WhereArrayIterator`1.MoveNext() +42
umbraco.cms.businesslogic.datatype.DataTypeDefinition.GetByDataTypeId(Guid DataTypeId) +311
umbraco.controls.Images.UploadMediaImage..ctor() +88
ASP.umbraco_controls_images_uploadmediaimage_ascx..ctor() in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\1096afd0\6b67abfd\App_Web_uploadmediaimage.ascx.c3c18f9f.5y91thdt.0.cs:0
ASP.umbraco_plugins_tinymce3_insertimage_aspx.__BuildControlMediaUploader() in c:\work\IU\trunk\src\International.Web.UI\umbraco\plugins\tinymce3\insertImage.aspx:187
ASP.umbraco_plugins_tinymce3_insertimage_aspx.__BuildControlpane_upload() in c:\work\IU\trunk\src\International.Web.UI\umbraco\plugins\tinymce3\insertImage.aspx:186
ASP.umbraco_plugins_tinymce3_insertimage_aspx.__BuildControlForm1() in c:\work\IU\trunk\src\International.Web.UI\umbraco\plugins\tinymce3\insertImage.aspx:150
ASP.umbraco_plugins_tinymce3_insertimage_aspx.__BuildControlTree(umbraco_plugins_tinymce3_insertimage_aspx __ctrl) in c:\work\IU\trunk\src\International.Web.UI\umbraco\plugins\tinymce3\insertImage.aspx:1
ASP.umbraco_plugins_tinymce3_insertimage_aspx.FrameworkInitialize() in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\1096afd0\6b67abfd\App_Web_insertimage.aspx.43b758d9.qhb5uafm.0.cs:0
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +67
System.Web.UI.Page.ProcessRequest() +118
System.Web.UI.Page.ProcessRequest(HttpContext context) +98
ASP.umbraco_plugins_tinymce3_insertimage_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\1096afd0\6b67abfd\App_Web_insertimage.aspx.43b758d9.qhb5uafm.0.cs:0
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +912
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +164
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18033
Two things that spring to mind:
Permissions
I would do the usual housekeeping check first. Ensure that the following accounts have modify permission on all of the site's folders:
NETWORK SERVICE
IUSR
IIS_IUSRS
Corrupted install
A final resort would be a re-install. Copy over all the files from your version of Umbraco. If this still doesn't work, point it at a new database and try re-installing a basic Umbraco website.
The idea here is to determine if it is a corrupted database record, or a missing/corrupted file.
Is the site a new one? Have you always stuck with the same version or recently upgraded?
Let us know if you have your own answer too please. Best of luck!

Arithmetic operation resulted in an overflow

The application is working well in Win server 2003 /IIS 6.0 environment.
When I move the code to win server 2008/IIS 7.0 , I am getting below error? Could you advise what is the error cause? Did i missed anything?
Server Error in '/' Application.
Arithmetic operation resulted in an overflow.
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.OverflowException: Arithmetic operation resulted in an overflow.
Stack Trace:
[OverflowException: Arithmetic operation resulted in an overflow.]
System.IntPtr.ToInt32() +37
CoreLab.Common.a.a(Delegate A_0) +1935
CoreLab.Oracle.ab.a(OracleConnection A_0) +214
CoreLab.Oracle.OracleConnection.Open() +375
MonsterWorldwide.iTime.DataAccess.TimecardDA.GetTimecardPageInfoSet(Int32 personId, Int32 pageNumber, Int32 rowsPerPage, Int32& rowsCountTotal) in c:\inetpub\wwwroot\mtitimeproduction\dataaccess\timecardda.cs:28
MonsterWorldwide.iTime.BusinessLogic.TimecardBL.GetTimecardPageInfoSet(Int32 personId, Int32 pageNumber, Int32 rowsPerPage, Int32& rowsCountTotal) in c:\inetpub\wwwroot\mtitimeproduction\businesslogic\timecardbl.cs:24
MonsterWorldwide.iTime.WebGUI.WebParts.TimecardList.LoadData() in c:\inetpub\wwwroot\mtitimeproduction\webgui\webparts\timecardlist.ascx.cs:112
MonsterWorldwide.iTime.WebGUI.WebParts.TimecardList.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\mtitimeproduction\webgui\webparts\timecardlist.ascx.cs:52
System.Web.UI.Control.OnLoad(EventArgs e) +132
System.Web.UI.Control.LoadRecursive() +66
System.Web.UI.Control.LoadRecursive() +191
System.Web.UI.Control.LoadRecursive() +191
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428
Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4927
[OverflowException: Arithmetic operation resulted in an overflow.]
System.IntPtr.ToInt32() +37
CoreLab.Common.a.a(Delegate A_0) +1935
CoreLab.Oracle.ab.a(OracleConnection A_0) +214
This looks like some poorly written unmanaged interop code which doesn't take into account the CPU type and which blows when run in a x64 bit OS. In a 64-bit OS pointers are 64-bit integers contrary to 32 bit OS.
Maybe you should check the documentation of this CoreLab.Common component you are using whether it supports 64-bit systems.
Quote from the documentation of the IntPtr.ToInt32 method:
OverflowException: On a 64-bit platform, the value of this instance is too large or too small to represent as a 32-bit signed integer.

Resources