How can I fix this? System.NullReferenceException: Object reference not set to an instance of an object - .net-4.5

just having some problem with the new IIS and ASP.Net4, i was using an upload system in an old version of both in an old server.
Now my request was to put the upload system into a new server and make it run. It was easy at the beginning, but now I have some problems with it. I can loggin and download files, that works great, but if I just try to upload a file, then i get an error like this:
Server Error in '/DownloadManager' Application.
System.NullReferenceException: Object reference not set to an instance
of an object. at
DimpleSoftwares.KFileUploadPlus.KRequestStream.ReadPreloaded(Byte[]
buffer, Int32 offset, Int32 count) at
DimpleSoftwares.KFileUploadPlus.KRequestStream.Read(Byte[] buffer,
Int32 offset, Int32 count) at
DimpleSoftwares.KFileUploadPlus.KUploadRequest..ctor(KRequestStream s,
String strFileName, UploadModule UpLoadModule, Encoding encoding)
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.Exception: System.NullReferenceException:
Object reference not set to an instance of an object. at
DimpleSoftwares.KFileUploadPlus.KRequestStream.ReadPreloaded(Byte[]
buffer, Int32 offset, Int32 count) at
DimpleSoftwares.KFileUploadPlus.KRequestStream.Read(Byte[] buffer,
Int32 offset, Int32 count) at
DimpleSoftwares.KFileUploadPlus.KUploadRequest..ctor(KRequestStream s,
String strFileName, UploadModule UpLoadModule, Encoding encoding)
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:
[Exception: System.NullReferenceException: Object reference not set to
an instance of an object. at
DimpleSoftwares.KFileUploadPlus.KRequestStream.ReadPreloaded(Byte[]
buffer, Int32 offset, Int32 count) at
DimpleSoftwares.KFileUploadPlus.KRequestStream.Read(Byte[] buffer,
Int32 offset, Int32 count) at
DimpleSoftwares.KFileUploadPlus.KUploadRequest..ctor(KRequestStream s,
String strFileName, UploadModule UpLoadModule, Encoding encoding)]
DimpleSoftwares.KFileUploadPlus.KUploadRequest..ctor(KRequestStream s,
String strFileName, UploadModule UpLoadModule, Encoding encoding)
+2225 DimpleSoftwares.KFileUploadPlus.UploadModule.context_BeginRequest(Object
sender, EventArgs e) +1766
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+80 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165
I just wondering how can I fix that? I have to add the modules manually in IIS? because for example i don´t find the System.Web.SyncEventExecutionStep or System.Web.HttpApplication.ExecuteStep
I really misst something and I don´t see it...

I've encountered a similar problem "Object reference not set to an instance of an object" before and it was primarily due to .NET v4.5.
If it's possible (unless you really need v4.5), can you try downgrading .NET Framework from v4.5 to just v4.0 and run the code again. The version 4.5 doesn't actually show up in IIS ApplicationPool so there might be a confusion when you see that your web app shows you that it's using v4.0. Note that when you uninstall 4.5 you have to reinstall v4.0 because uninstalling v4.5 takes down v4.0 with it unlike the previous version of .NET (eg v3.0, v3.5 where removing 3.5 won't necessarily remove 3.0).
Hope this helps somehow.

I know it's too late but it would help someone else.
Just go to Application properties-> Build -> Change the Platform Target to x64 or 'Any CPU'.
With this setting it should work.

Related

Unity WebGL - Locating code that triggers Reflection.emit

I've run into the dreaded Reflection.emit issue in my webplayer build and am unable to locate what is triggering it. I'm currently commenting out code method by method and rebuilding to locate the cause and have narrowed it down to the below.
I'm not using JSON so the various JSON libraries aren't the cause, nor any of the other result suggestions returned by google.
How can i more easily go about locating the cause of this error. I have full stack trace on and well as full debugging, but all i get is the following console output.
NotSupportedException: C:\Program Files\Unity 2018.2.0b2\Editor\Data\il2cpp\libil2cpp\icalls\mscorlib\System.Reflection.Emit\AssemblyBuilder.cpp(20) : Unsupported internal call for IL2CPP:AssemblyBuilder::basic_init - System.Reflection.Emit is not supported.
Rethrow as TypeInitializationException: The type initializer for 'System.Reflection.Emit.DynamicMethod.AnonHostModuleHolder' threw an exception.
//NOTE: appM.procM is a C# .Net 4.x dynamic variable EG:
//public dynamic procM = GetProcClass(strProcName)
public void ShowProcList() {
/* Rest of method commented out*/
if(appM.procM == null){
procList.Initialize(appM.procM.lstNames, this);
}
/* Rest of method commented out*/
}
public void Initialize(List<string> lstNames, UIM um, string currProc=null) {
uiM = um;
//cleanup of the list before populating
foreach(Transform fld in Panel.transform) {
Destroy(fld.gameObject);
}
/* Rest of method commented out*/
}
Update: I narrowed down the problem line of code, but haven't closed the question as there's got to be an easier way than commenting out line by line and rebuilding.
For future searchers, the issue is the if(appM.procM == null) check. As procM is a dynamic variable reflection is used which kills AOT in webGL builds. No compiler warnings were generated to save myself from myself.
Nevermind, i am an idiot, The option Enable Exceptions under Player Settings was set to Full Without Stacktrace and not Full with Stacktrace.
The value Full With Stacktrace contains the pertinent data. Easily locatable in the browsers console. Warning that full debugging does increase build times and slow down the application.

CRM 2016 online - debug custom workflow activity crashes plugin registration tool

I wanted to use Plugin Registration Tool (from now on referenced as PRT) to debug custom workflow activity with CRM 2016 online. My problem is that whenever I click on "Profile Workflow" button, PRT crashes.
Details on crash are found in event log and are stated below.
Event log entry one:
Faulting application name: PluginRegistration.exe, version: 8.2.1.8676, time stamp: 0x58d073d5
Faulting module name: KERNELBASE.dll, version: 10.0.15063.296, time stamp: 0xa0527b0c
Exception code: 0xe0434352
Fault offset: 0x0000000000069e08
Faulting process id: 0xb70
Faulting application start time: 0x01d2ea6794b7727a
Faulting application path: D:_temp\SDK\Tools\PluginRegistration\PluginRegistration.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: 21f5bf85-22be-44ca-b884-ef43d9490886
Faulting package full name:
Faulting package-relative application ID:
Event log entry two:
Application: PluginRegistration.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Xml.XPath.XPathException
at MS.Internal.Xml.XPath.XPathParser.CheckToken(LexKind)
at MS.Internal.Xml.XPath.XPathParser.ParsePredicate(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseStep(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParsePathExpr(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseUnionExpr(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseMultiplicativeExpr(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseAdditiveExpr(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseRelationalExpr(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseEqualityExpr(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseAndExpr(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseOrExpr(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseExpresion(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseXPathExpresion(System.String)
at System.Xml.XPath.XPathExpression.Compile(System.String, System.Xml.IXmlNamespaceResolver)
at System.Xml.XPath.XPathNavigator.Compile(System.String)
at System.Xml.XmlNode.SelectSingleNode(System.String, System.Xml.XmlNamespaceManager)
at PluginProfiler.Library.WorkflowXamlUtility.GetCustomActivityFullyQualifiedName(System.String, System.Xml.XmlNode, System.Xml.XmlNamespaceManager)
at PluginProfiler.Library.WorkflowXamlUtility.GetCustomActivityFullyQualifiedNames(Microsoft.Xrm.Tooling.Connector.CrmServiceClient, System.Xml.XmlDocument, System.Xml.XmlNamespaceManager)
at PluginProfiler.Library.WorkflowXamlUtility.GetWorkflowActivitySteps(Microsoft.Xrm.Tooling.Connector.CrmServiceClient, System.String)
at Microsoft.Crm.Tools.PluginRegistration.CommonControls.ExistingWorkflow.Refresh()
at Microsoft.Crm.Tools.PluginRegistration.CommonControls.ProfilerSettingsViewModel.set_SelectedWorkFlow(Microsoft.Crm.Tools.PluginRegistration.CommonControls.ExistingWorkflow)
at Microsoft.Crm.Tools.PluginRegistration.CommonControls.ProfilerSettingsViewModel.RefreshWorkflows()
at Microsoft.Crm.Tools.PluginRegistration.CommonControls.ProfilerSettingsViewModel..ctor(Microsoft.Crm.Tools.Libraries.CrmOrganization, PluginProfiler.OperationType, System.Guid, Microsoft.Crm.Tools.PluginRegistration.CommonControls.ProfilerSettingsView)
at Microsoft.Crm.Tools.PluginRegistration.OrganizationControlViewModel.StartProfiler_Clicked()
at Microsoft.Crm.Tools.PluginRegistration.OrganizationControlViewModel.MenuItem_Clicked(System.Object)
at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(System.Windows.Input.ICommandSource, Boolean)
at System.Windows.Controls.MenuItem.InvokeClickAfterRender(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
at System.Windows.Application.RunDispatcher(System.Object)
at System.Windows.Application.RunInternal(System.Windows.Window)
at Microsoft.Crm.Tools.PluginRegistration.App.Main()
Both event log entries are created at same time when plugin crashed.
I've spent last our googling, trying to find someone with at least similar problem, but I failed :)
Is there any solution for this?
I've seen behavior like this before with plugins and custom workflow activities depending on the actions taken within the code. For example, if my plugin does an http request I've seen that crash the PRT, I don't know for sure but it may be that the PRT doesn't allow that type of thing if it's debugging in a sandboxed environment.
An alternative to directly debugging the custom workflow activity or plugin is to create a new custom entity with some fields to store information such as the user id the code is running as, the name of the plugin or workflow activity, exception message, etc. and then in the code write to a StringBuilder object in the same way you might write useful information out to the tracing object. In a catch block or always at the end of the code you can create a new record of the custom entity and store the information from the StringBuilder and plugin context, etc. I've used this in a lot of situations where I want to output custom detailed info for debugging or testing as long as the plugin doesn't need to throw an exception which will roll back the transaction. It may seem tedious to add the extra code to output what you want but if debugging isn't an option this will work.
Example code to illustrate what I mean...
Dim tracer As New StringBuilder
Try
tracer.Append("running code ...")
'// do some code here
tracer.AppendLine("done")
tracer.Append("running more code ...")
'// do some code here
tracer.AppendLine("done")
'// Write out some info useful for debugging
tracer.AppendLine(String.Format("value of variable 1 {0}", SomeVariable1))
Catch ex As Exception
tracer.AppendLine(ex.ToString)
End Try
'// Create a new instance of the new custom error entity and save it
'// Where CustomError is the name of your new entity, assuming you're using strongly-typed entity classes
Dim ErrorObj As New CustomError With {
.UserName = "",
.Message = tracer.ToString
}
pluginOrgService.Create(ErrorObj)
I've contacted MS support, exchanged emails with them for couple od days, even had a remote session with their support, then waited couple more days for their support to analyze problem, never got any solution from MS support, and at the end I overcome this by my own.
Problem here is with tool as I wanted to report to MS, but for some reason they are convinced that problem is with my custom code. I managed to narrow down this to one specific custom workflow that I made, lets call it Workflow_A. When plugin registration tool (PRT) try to get list of workflows from CRM (I used Fiddler, there is no order by in that request), Workflow_A was first in that list, PRT could not parse it and crashed. I then, deleted that workflow and recreated it again (same steps and conditions) and voila, it ended as last in workflows list and PRT stop crashing.
AK3800 stated
if my plugin does an http request I've seen that crash the PRT, I don't know for sure but it may be that the PRT doesn't allow that type of thing if it's debugging in a sandboxed environment.
I had to agree with him - PRT is making more problems then it solves (with debugging) so at the end I ended up filling my code with trace logs everywhere and no debugging, just making code changes based on trace logs.
I'd open a support ticket with MS. They offer support for the SDK tools as well.

Program crashes while executed in release visual c++

I have just begun to use Visual C++ 2008 to create an app for my PC.
Program work both in debug and release mode when its run from visual c++.
When I run release when is visual c++ closed and click on buttons unhandled exception occurred.
So what does that actually mean? How to solve the problem ?
Thanks
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.OverflowException: Value was either too large or too small for a character.
at System.Convert.ToChar(Int32 value)
at gorskikotar.Form1.chekSum(String DtCS) in c:\users\freza\desktop\ozalj jednajedinica v100\gorskikotar\form1.h:line 1151
at gorskikotar.Form1.slanjeKomande(String tip, String group, String unit, String komanda) in c:\users\freza\desktop\ozalj jedna jedinica v100\gorskikotar\form1.h:line 1127
at gorskikotar.Form1.testAlarmi(String group, String unit) in c:\users\freza\desktop\ozalj jedna jedinica v100\gorskikotar\form1.h:line 1024
at gorskikotar.Form1.uredajiZaTest() in c:\users\freza\desktop\ozalj jedna jedinica v100\gorskikotar\form1.h:line 1011
at gorskikotar.Form1.button8_Click(Object sender, EventArgs e) in c:\users\freza\desktop\ozalj jedna jedinica v100\gorskikotar\form1.h:line 529
I found your problem: In the code you linked to (it should really be in the question) you declare the variable sum, but you do not initialize it. Visual Studio is helpful and clears it for you, but when running outside of VS, then this variable can be anything.
Change declaration line to:
long sum = 0, i, a, b;

Unhandled exception - just in time debugging

I have an application (extension) that works fine on Windows XP platform. When I run this application on Windows 7 it throws this error. I am not sure what is causing this. I was thinking that it could be due to the fact that .net framework is not installed but I can see all in there. Looking for any ideas to resolve this issue.
Note: this error comes up when I click on a combox box. How can i get past this message box and get to actual error.
Thanks
Jay
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at MapExt_Net.HEI_Extensions.layout.frmLayout.DisplaySize()
at MapExt_Net.HEI_Extensions.layout.frmLayout.cBLayoutExtent_SelectedIndexChanged(Object sender, EventArgs e)
at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
at System.Windows.Forms.ComboBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
The exception is raised in MapExt_Net.HEI_Extensions.layout.frmLayout.DisplaySize() which seems to be implemented by yourself. Could you please paste the code of the method?

IWebBrowser2 Quit method fails with a E_FAIL result

I am hosting the web browser control in my own window. Here are the pertinent steps:
CoGetClassObject(CLSID_WebBrowser,
CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
NULL, IID_IClassFactory, (void **)&pClassFactory);
pClassFactory->CreateInstance(0, IID_IOleObject, (void **)&pObject);
pClassFactory->Release();
pObject->SetClientSite((IOleClientSite *)impl)
OleSetContainedObject((struct IUnknown *)pObject, true)
pObject->DoVerb(OLEIVERB_SHOW, NULL, (IOleClientSite *)impl, 0, hHpsWnd, &rect);
pWB->put_Visible(VARIANT_FALSE);
hr=pWB->Quit();
At the last statement above the hr return value is E_FAIL. The end result of this failure in my code is leaking of a bunch of resources. What am I doing incorrectly?
Reading the documenation here it states the WebBrowser object (i.e. CLSID_WebBrowser) returns an error from the Quit method because it does not make sense in context. The Quit method will quit the out of process version of IE which also uses the same interface to communicate.
Only thing I can suggest is double check you are releasing all COM object relating to the browser.