Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all 1710 articles
Browse latest View live

Register old assembly (Interop.MSFlexGridLib.dll)

$
0
0

I've a program that uses the Interop.MSFlexGridLib.dll assembly and I cannot use gacutil to install in the GAC as it doesn't have a strongly typed name.  If you install the program from my distribution MSI it all works (and run that instance of the exe) it all works fine.  However I changed laptops and have had to re-add my projects references and hence I have found this problem (running VS 2013 on windows 8).

Does anyone now how I can register the dll in GAC ??

Urgent that I resolve this so any and all ideas appreciated.

Thanks, Tim


Thank you for you time folks!


Wrong file path and line number in Exception stack traces from dynamic code

$
0
0

We are using System.Reflection.Emit to generate code at runtime from source code (yes - as in a compiler). We provide correct symbol information to the ILGenerator with MarkSequencePoint etc, and enable all debug flags on the AssemblyBuilder. The assembly is kept in memory in the same process that compiled it and is executed directly.

When using the Visual Studio debugger to step through the source for the dynamically generated code it actually works perfectly, and Visual Studio seems to be fully aware of where code comes from in terms of files and line numbers.

HOWEVER - When exceptions are thrown by the generated code, the System.Exception objects contain stack traces that are completely wrong. They point to other (valid, but wrong) files and line numbers. It gets the class and method name right, but the file and line number pointed to has nothing to do with the code path the exception actually came from.

The files pointed to are so unrelated it seems it can't be linked to inlining or optimizations. The only pattern I can spot is that it seems to be offset by some files (in an imaginary alphabetically sorted list of source files the assembly was built from). However, this pattern is not 100% consistent, and it seems irrational that this is linked to the source of the problem.

If i construct a System.Diagnostics.Debug object from the Exception, it contains the same faulty information.

I am assuming that the .NET runtime uses the same metadata to construct Exception stack traces as the debugger uses for stepping through the code, in which case this behavior is really weird.

When trying to reproduce the problem with a much simpler project, the error does *not* occur, so unfortunately i have not been able to produce a minimal test case. The real case is quite complex.

I'm trying to find out if this is a known bug in .NET when dealing with dynamic in-memory assemblies, or if anyone has seen similar problems in other areas.

Regarding internet connection in VMware player with Windows 8.1

$
0
0

hi,

After updating OS in my laptop from windows 8 to 8.1, I am unable to connect to internet inside VMware Player. I have tried to troubleshoot the issue but ended up with nothing. Is this a known issue ?

-Varun

VS 2010 Managed Debugging Assistant 'LoaderLock' has detected a problem in 'C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE'

$
0
0

Hello,

I trying to debug a c# project using VS 2010. I have defined Excel as the start up application in the property window of the project.  I have created a couple of break points and I am getting the following errors.  I am not sure if all of these errors are related. Please assist to figure out the problem and how to fix it.  Thank you


A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in MYAppClient.Office.dll
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'C:\win32_x86\Debug\bin\MYAppClient\NET40\BusinessObjects.DSWS.Session.dll'
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'C:\win32_x86\Debug\bin\MYAppClient\NET40\BusinessObjects.DSWS.dll'
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll'
Managed Debugging Assistant 'LoaderLock' has detected a problem in 'C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE'.
Additional Information: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.

Failed to start a new STA thread

$
0
0
Hi!

We are having some really weird failures where a .NET 1.1 dll fails to start a new STA thread. The weird part is that the caller does not get any kind of exception (except the one that we are throwing because the resetEvent.WaitOne won't succeed within 5 minutes).

The method is called from a Biztalk 2004 orchestration. The worker thread does use a 3rd party com-dll that won't work in MTA.  

Here is a short code snippet to show what we are trying to do.

    public abstract class MyBaseClass
    {
        private ManualResetEvent resetEvent = new ManualResetEvent(false);

        protected void Execute()
        {
            try
            {
                Thread STAThread = new Thread(new ThreadStart(RunCommand));
                STAThread.ApartmentState = ApartmentState.STA;
                STAThread.Name = "STA worker";

                STAThread.Start();

                if (!resetEvent.WaitOne(new TimeSpan(0, 0, 5, 0, 0), false))
                {
                    throw new ApplicationException("Thread did not respond within timeout limit");
                }
            }
            catch (Exception ex)
            {
                // dumping of the exception to the eventlog omitted for brevity
                throw;
            }
        }

        private void RunCommand()
        {
            try
            {
                /*
                 * this  is where the real work is done
                 */ 
            }
            catch ( Exception ex)
            {
                // dumping of the exception to the eventlog omitted for brevity
                throw;
            }
            finally
            {
                resetEvent.Set();
            }
        }
    }


I've added a lot of debugging code the that function. It shows that most of the time the function works fine but a few times a day the child-thread just don't start.

We've also noticed that quite often it takes a few seconds before the runcommand delegate really does anything.

Do you have any idea what could cause this and how to investigate this further?

With regards

Tapio Kulmala

Add new tab in windows File (how)

$
0
0
Hello Programmers, Can someone tell how to add a new tab in a file in Windows 7 using C#?

How to use OpCode Jmp and Calli on ILGenerator ?

$
0
0

Hi, guy

Could anyone give me some example how to use those 2 OpCode, I'm search and try in many way but non success (MSDN library not helpful in this case at all).

Stackoverflow exception in .net 4

$
0
0

Hi,

We've been struggling with this strange issue for a while and we'd appreciate it if anyone can assist...

After upgrading our product to work with .net4 (we successfully used .net 3.5 until now) we suddenly started getting stackoverflow exceptions (it doesn't always happen and not on all machines but we have a machine that it happens constantly).

We used ADPlus to get a dump and found the thread that throws the exception.

Printing the clrstack showed the following for that thread:

ChildEBP RetAddr 

03012ffc 72467628 clrjit!Compiler::gtNewNode+0x2

03013008 72467724 clrjit!Compiler::gtNewOperNode+0xd

03013020 7247a992 clrjit!Compiler::gtNewAssignNode+0x2d

03013038 7247bc1d clrjit!Compiler::gtNewTempAssign+0x86

03013054 72480f79 clrjit!Compiler::impAssignTempGen+0x54

0301308c 72494351 clrjit!Compiler::impSpillStackEntry+0xea

030130a4 7246645d clrjit!Compiler::impSpillSpecialSideEff+0x3b

030130c0 72467afc clrjit!Compiler::impSpillSideEffects+0x11

030130e0 7247bc44 clrjit!Compiler::impAppendStmt+0x92

030130f8 72480f79 clrjit!Compiler::impAssignTempGen+0x97

03013130 72494351 clrjit!Compiler::impSpillStackEntry+0xea

03013148 7246645d clrjit!Compiler::impSpillSpecialSideEff+0x3b

03013164 72467afc clrjit!Compiler::impSpillSideEffects+0x11

03013184 7247bc44 clrjit!Compiler::impAppendStmt+0x92

0301319c 72480f79 clrjit!Compiler::impAssignTempGen+0x97

030131d4 72494351 clrjit!Compiler::impSpillStackEntry+0xea

030131ec 7246645d clrjit!Compiler::impSpillSpecialSideEff+0x3b

03013208 72467afc clrjit!Compiler::impSpillSideEffects+0x11

03013228 7247bc44 clrjit!Compiler::impAppendStmt+0x92

03013240 72480f79 clrjit!Compiler::impAssignTempGen+0x97

03013278 72494351 clrjit!Compiler::impSpillStackEntry+0xea

03013290 7246645d clrjit!Compiler::impSpillSpecialSideEff+0x3b

030132ac 72467afc clrjit!Compiler::impSpillSideEffects+0x11

030132cc 7247bc44 clrjit!Compiler::impAppendStmt+0x92

030132e4 72480f79 clrjit!Compiler::impAssignTempGen+0x97

0301331c 72494351 clrjit!Compiler::impSpillStackEntry+0xea

03013334 7246645d clrjit!Compiler::impSpillSpecialSideEff+0x3b

03013350 72467afc clrjit!Compiler::impSpillSideEffects+0x11

03013370 7247bc44 clrjit!Compiler::impAppendStmt+0x92

03013388 72480f79 clrjit!Compiler::impAssignTempGen+0x97

030133c0 72494351 clrjit!Compiler::impSpillStackEntry+0xea

030133d8 7246645d clrjit!Compiler::impSpillSpecialSideEff+0x3b

030133f4 72467afc clrjit!Compiler::impSpillSideEffects+0x11

03013414 7247bc44 clrjit!Compiler::impAppendStmt+0x92

0301342c 72480f79 clrjit!Compiler::impAssignTempGen+0x97

03013464 72494351 clrjit!Compiler::impSpillStackEntry+0xea

0301347c 7246645d clrjit!Compiler::impSpillSpecialSideEff+0x3b

03013498 72467afc clrjit!Compiler::impSpillSideEffects+0x11

030134b8 7247bc44 clrjit!Compiler::impAppendStmt+0x92

and so on, the pattern continues...

It looks like the stackoverflow comes from clrjit code.

Has anyone had this issue before?

Any advice \ idea would be appreciated.

Thanks.


Same assembly of different versions be loaded into same AppDomain

$
0
0

We developed a component which can be used by our customer to develop the DTM (A DTM is also a component, you can think of it as logical representation of automation smart device). Our customer created two DTMs, one is Communication DTM (provides communication ability) created based on latest version of our component (dtmMANAGER3 version 1.4.0.0), and the other one is normal device DTM created based on old version of our component (version 1.3.0.0). And there is a application called Frame Application, this application can load all the DTMs and create a topoloy with these DTMs (The topology is same as the topology of the corresponding physical devices in the field, for example a communication device is parent of a gateway device, and the gateway device is parent of normal smart device).

Our customer create a simple topology with these two DTMs, so the assemblies of these DTMs and their dependencies be loaded into same AppDomain. This causes two different versions of our component (dtmMANAGER3 Version 1.3.0.0 and 1.4.0.0) be loaded into same AppDomain. These two DTMs doesn't directly communication with each other(all the communication will go through FrameApplication), so we think it's ok for two different version of our component be loaded into same AppDomain (Our component has been strong-name signed).

These two DTMs work fine, except the WPF UI. In the xaml file it uses custom control from our component.

Here is the sequence:

1. Add the Communication DTM to the topology which will cause the dtmMANAGER3 component 1.4.0.0 be loaded into the AppDomain.

2. The WPF UI of the Communicaiton DTM can be opened.

3. Add the Device DTM to the topology as the child of the CommunictionDTM, this will caue the dtmMANAGER3 component 1.3.0.0 be loaded into the AppDomain.

4. If we open the WPF UI of the Communication DTM, it won't shown the UI. The WPFUI of communication DTM throws an XamlParseException.

I read this article http://msdn.microsoft.com/en-us/library/ms747086(v=vs.110).aspx.

In the "WPF and Assembly Loading" paragraph, it says: "Iterate through the AppDomain, looking for an already-loaded assembly that matches all aspects of the name, starting from the most recently loaded assembly."

In our scenario the recently loaded assembly is dtmMANAGER3 1.3.0.0 (the dtmMANAGER3 1.4.0.0 is loaded earlier). But the WPF UI of the Communcation DTM should works with the dtmMANAGER3 1.4.0.0. Is this the cause of our problem? If so is there any solution for this?

How to avoid this Memory Leak?

$
0
0

Hi,

I'm getting 'Not enough storage space available to process this command' error after executing the application for some time.

The following is the analysis report of my application using Debugdiag.

Handle  0x00000000
Allocation Time  00:12:47 since tracking started
Function  Destination
WindowsCodecs!CircularBuffer::~CircularBuffer+217  kernel32!CreateFileMappingA
WindowsCodecs!CDecoderBase::CopyPixels+1c3  
WindowsCodecs!CDecoderFrame::CopyPixels+87  
GdiPlus!GpWicDecoder::Decode+14c  
GdiPlus!GpDecodedImage::InternalPushIntoSink+2d  
GdiPlus!GpDecodedImage::PushIntoSink+3c  GdiPlus!GpDecodedImage::InternalPushIntoSink
GdiPlus!GpMemoryBitmap::InitImageBitmap+15f  
GdiPlus!GpMemoryBitmap::CreateFromImage+51  GdiPlus!GpMemoryBitmap::InitImageBitmap
GdiPlus!CopyOnWriteBitmap::LoadIntoMemory+85  GdiPlus!GpMemoryBitmap::CreateFromImage
GdiPlus!GpBitmap::ForceValidation+18  GdiPlus!CopyOnWriteBitmap::LoadIntoMemory
GdiPlus!GdipImageForceValidation+77  GdiPlus!GpBitmap::ForceValidation
0x51B912  
mscorwks!NDirectMethodFrameStandalone::`vftable'  
mscorwks!CallDescrWorker+33  
mscorwks!CallDescrWorkerWithHandler+a3  mscorwks!CallDescrWorker
mscorwks!MethodDesc::CallDescr+19c  mscorwks!CallDescrWorkerWithHandler
mscorwks!MethodDesc::CallTargetWorker+1f  mscorwks!MethodDesc::CallDescr
mscorwks!MethodDescCallSite::Call_RetArgSlot+1a  mscorwks!MethodDesc::CallTargetWorker
mscorwks!ReflectionInvocation::MakeTypedReference+4f7  mscorwks!MethodDescCallSite::Call_RetArgSlot
mscorwks!RuntimeMethodHandle::SerializationInvoke+36  
mscorwks!HelperMethodFrame_PROTECTOBJ::`vftable'  
mscorwks!RuntimeMethodHandle::SerializationInvoke  
System.RuntimeType.GetHashCode()  
System_Drawing_ni+380f0  
System_Drawing_ni+bd20e  
System_Drawing_ni+bd20e  
System_Drawing_ni+bd20d  
System_Drawing_ni+bd20b  
mscorwks! ?? ::FNODOBFM::`string'+2ae53  
System_Drawing_ni+bd20b  
System_Drawing_ni+380f0  
System_Drawing_ni+5ca1c  
mscorlib_ni+270460  
System_Drawing_ni+bd20b  
System_Drawing_ni+5ca1c  
mscorlib_ni+270460  
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(System.Runtime.Remoting.Messaging.HeaderHandler, System.Runtime.Serialization.Formatters.Binary.__BinaryParser, Boolean, Boolean, System.Runtime.Remoting.Messaging.IMethodCallMessage)  
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(System.IO.Stream, System.Runtime.Remoting.Messaging.HeaderHandler, Boolean, Boolean, System.Runtime.Remoting.Messaging.IMethodCallMessage)  System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(System.Runtime.Remoting.Messaging.HeaderHandler, System.Runtime.Serialization.Formatters.Binary.__BinaryParser, Boolean, Boolean, System.Runtime.Remoting.Messaging.IMethodCallMessage)
System.Resources.ResourceReader.DeserializeObject(Int32)  System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(System.IO.Stream, System.Runtime.Remoting.Messaging.HeaderHandler, Boolean, Boolean, System.Runtime.Remoting.Messaging.IMethodCallMessage)
System.Resources.ResourceReader.LoadObjectV2(Int32, System.Resources.ResourceTypeCode ByRef)  System.Resources.ResourceReader.DeserializeObject(Int32)
System.Resources.ResourceReader.LoadObject(Int32, System.Resources.ResourceTypeCode ByRef)  System.Resources.ResourceReader.LoadObjectV2(Int32, System.Resources.ResourceTypeCode ByRef)
System.Resources.RuntimeResourceSet.GetObject(System.String, Boolean, Boolean)  System.Resources.ResourceReader.LoadObject(Int32, System.Resources.ResourceTypeCode ByRef)
System.Resources.RuntimeResourceSet.GetObject(System.String, Boolean)  System.Resources.RuntimeResourceSet.GetObject(System.String, Boolean, Boolean)
System.Resources.ResourceManager.GetObject(System.String, System.Globalization.CultureInfo, Boolean)  
System.Resources.ResourceManager.GetObject(System.String, System.Globalization.CultureInfo)  System.Resources.ResourceManager.GetObject(System.String, System.Globalization.CultureInfo, Boolean)
ControlsLib.Properties.Resources.get_Filter_On()  
ControlsLib.UserControls.DetailGridManager.InitializeComponent()  ControlsLib.Properties.Resources.get_Filter_On()
mscorwks!CallDescrWorker+33  
mscorwks!CallDescrWorkerWithHandler+a3  mscorwks!CallDescrWorker
mscorwks!CallDescrWorker+33  
mscorwks!CallDescrWorkerWithHandler+a3  mscorwks!CallDescrWorker
mscorwks!MethodDesc::CallDescr+19c  mscorwks!CallDescrWorkerWithHandler
mscorwks!MethodDesc::CallTargetWorker+1f  mscorwks!MethodDesc::CallDescr
mscorwks!MethodDescCallSite::Call_RetArgSlot+1a  mscorwks!MethodDesc::CallTargetWorker
mscorwks!ClassLoader::RunMain+223  mscorwks!MethodDescCallSite::Call_RetArgSlot
mscorwks!Assembly::ExecuteMainMethod+a6  mscorwks!ClassLoader::RunMain
mscorwks!SystemDomain::ExecuteMainMethod+45e  mscorwks!Assembly::ExecuteMainMethod
mscorwks!ExecuteEXE+59  mscorwks!SystemDomain::ExecuteMainMethod
mscorwks!_CorExeMain+15c  mscorwks!ExecuteEXE
mscoreei!_CorExeMain+10a  
kernel32!GetProcAddressStub  
mscorwks!_CorExeMain  
mscoree!ShellShim__CorExeMain+99  
mscoree!_CorExeMain_Exported+8  mscoree!ShellShim__CorExeMain
kernel32!BaseThreadInitThunk+e  
ntdll!__RtlUserThreadStart+70  
ntdll!_RtlUserThreadStart+1b  ntdll!__RtlUserThreadStart
mscoree!_CorExeMain_Exported  

Expecting you valuable comments.

Thanks and regards,

Eins Antony




C# class indexer access from VB6 via COM interop

$
0
0

Hello,

I'm operating in a scenario where legacy VB6 code must interoperate with C# code. So far no problems except one special case where a C# library must substitude a former ActiveX-DLL.

The problem that arises is the indexer of a C# class that is being consumed from VB6. I can get values using the indexer without issues but when trying to set values from VB6 I'm running into error 424 "Object required".

Here's the C# code:

[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]  
[ComVisible(true)]    
public interface ITestList 
{         [DispId(0)]      Object this[short Index] 
     {             [DispId(0)]set;           [DispId(0)]get;          
     }        
}

[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
public class TestList : ITestList
{
    private List<Object> internalList = new List<Object>();

    public TestList()
    {
    }        

    public Object this[Object Index]
    {
        [return: MarshalAs(UnmanagedType.Struct)]
        get
        {
            // code for setter goes here
            return "test";                   
        }
        [param: MarshalAs(UnmanagedType.Struct)]
        set
        {
            // code for setter goes here but even without code the error occurs
        }
    }

}

Access from VB6 code:

'This is working
MsgBox obj.Item(1)
'This throws 424 "object required"
obj.Item(1) = "test me"

I've already investigated a lot but none of the findings solved the final problem. Please note that I'm not allowed to change the way VB6 is accessing the property. Thus the workaround to implement custom methods cannot be used.

I'm sure there's a way to implement the indexer in a way it's setter can be accessed from VB6 or at least I'd want to understand why this won't work.

Regards


how should machineKey be formatted in .net 4.5 webforms?

$
0
0

I recently migrated a web application from .net 3.5 to .net 4.5. The machineKey element is:

<machineKey validationKey="KeyA" decryptionKey="KeyB" validation="SHA1" decryption="3DES" compatibilityMode="Framework20SP1" />

I am getting hundreds of these errors:

Exception type: System.Web.HttpException
Exception message: Unable to validate data.
Request URL: http://imap.accoutrement.com.au/WebResource.axd?d=vIkcOYaxqSd6eMCUlxDkdQVxjxcaRV8fWPLFaNn8W4w1&t=633802992069218315&AspxAutoDetectCookieSupport=1
Request path: /WebResource.axd
Stack trace: at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Boolean useValidationSymAlgo, Boolean useLegacyMode, IVType ivType, Boolean signData)
at System.Web.UI.Page.DecryptString(String s, Purpose purpose)

ViewSource suggests the culprit could be an asp:Menu and/or viewstate.

Searching for a solution suggests machineKey could be the problem.

Thanks for any help.

CLR Profiling API - Detecting a field access

$
0
0
Is there a concrete way to find out if a specific field of a specific object is being accessed? It looks it would be possible to look at the IL and see for LdFld opcodes. Is that good enough? Are there other ways an objects field maybe accessed?

AccessViolationException with HandleProcessCorruptedStateExceptions not handled at runtime

$
0
0

I am calling a third-party unmanaged DLL from vb.net (framework 4.5) and on rare occasions the third party DLL thows an AccessViolationExcpetion ("Attempted to read or write protected memory. This is often an indication that other memory is corrupt."). 

I have added the <HandleProcessCorruptedStateExceptions> attribute to the method which calls the DLL as follows: -

    <Runtime.ExceptionServices.HandleProcessCorruptedStateExceptions> _
    <SecurityCritical> _
    Private Sub CallThirdParty()
            Try
                UnmanagedFunction(_outputFilename) ' this is the referenced with a DLLImport
            Catch ex As Exception
                ' example code to demonstrate handler
                Environment.Exit(0)
            End Try
    End Sub

When running in debug mode in VS2013 the exception is handled and the application quits as expected. However when I build and run the app outside of VS2013 it just hangs at this point and no exception is handled. The program doesn't even crash.

Is there anything I have missed here which makes debug vs build different?

Thanks for reading this...

Problems with MSVCR80.dll

$
0
0

It seem that the MSVCR80.dll is missing from my computer. This only happened today, when I tried to access Apple I-Tunes.

How to I:-

a) Get the file

b) install it in the appropriate space.

Please Help!

Tony


Random AppCrashes in clr.dll with .NET 4.0

$
0
0

Hi Everyone !

We are developing a 100% managed .NET Application/C# that consists of several Windows-Services and Client-Applications. Until April 2010 the Target was .Net 3.5 SP1. Meanwhile we converted all Projects to target .NET 4.0. And now we are expierencing APP-Crashes which happens every now and then (1 or twice a Week) if we are running our Tests on Win7 or 2008 R2.

The Faults are of Sort: 

Faulting application name: DoX.FX.ServerHostLoader.exe, version: 0.1.16070.73, time stamp: 0x4c403ab2

Faulting module name: clr.dll, version: 4.0.30319.1, time stamp: 0x4ba21eeb

Exception code: 0xc0000005

Fault offset: 0x00000000000026fe

Faulting process id: 0x5e8

Faulting application start time: 0x01cb404b8b0740a1

Faulting application path: C:\DoX.FX.ServerHostLoader.exe

Faulting module path: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll

Report Id: 2311172d-afbc-11df-9ded-0002b3c23d42

 

In some cases I get a Mini-Dump which I was able to debug to a certain point, the Methods where the crash happens are different e.g.

Process Architecture: x64
Exception Code: 0xC0000005
Exception Information: The thread tried to read from or write to a virtual address for which it does not have the appropriate access.
Heap Information: Not Present

System Information
------------------
OS Version: 6.1.7600
CLR Version(s): 4.0.30319.1

> clr.dll!JIT_ChkCastClassSpecial()  + 0x1e bytes 
  [Managed to Native Transition] 
  mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0xa1 bytes 
  mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x3b bytes 
  mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x4d bytes 
  [Native to Managed Transition] 
  kernel32.dll!BaseThreadInitThunk()  + 0xd bytes 
  ntdll.dll!RtlUserThreadStart()  + 0x21 bytes 

We now rolled back all our projects to .NET 3.5 Target, and the above AppCrash did not occur anymore (In a 1-Week continous Test). So we went searching for this error but suprisingly there are only few others that reported this error. Since this is an internal CLR-Error of .NET 4.0 we cannot believe that we are the only ones having this problem. But maybe the are more around also still trying to find a reason for it ? Would be glad to ge some Idea about this.

Sigi

 

 

 

 

OpCodes.Ldlen cause an error when put more then 1 pointer into IL stack before it.

$
0
0

Hi,

I'm write a for loop array test code, it's work fine until I put a check array size code (dup; ldlen; brfalse LabelExit;).
I find OpCodes.Ldlen is a cause of error, I fixed it but I don't know why it's error when I input 2 or more native int( as pointer) into stack before ldlen.

Code here.

'JIT.ObjectPointer is Intprt(as pointer) creator.
        Dim Arraier = JIT.ObjectPointer(New String() {"A", "B", "C", "D", "E", "F"})

'Dynamic.Method is similar System.Reflection.Emit.DynamicMethod include delegate type for CreateDelegate function later.
        With Dynamic.Method(Of System.Action).Create("Runing")

'Dynamic.Method.Craft is similar with ILGenerater 
            With .Craft(Of lbLoop)(This.Module)
                .Input(Arraier) 'ldc.i Arraier
                '.Duplicate() 'OpCode.Dup but I can't put it here, even I try to put ldc.i Arraier insert it but still cause error.
                .Objective.Length() 'ldlen
                .Break.OnFalse(lbLoop.Exiter) ' brfalse.s Label(lbLoop.Exiter)

                .Input(Arraier) 'Since I can't put duplicate command on above, I have to insert command here.
                .Input(0) 'ldc.i4.0
                .Point.Element(Of String)()' ldelema String

                .Break.Mark(lbLoop.Point) 'Point:

                .Duplicate()
                .Point.LoadAsObject(Of String)() 'ldobj String
                .Duplicate()
                .Break.OnFalse(lbLoop.Exiter)

                .Invoke(GetType(System.Console).GetMethod("WriteLine", {GetType(String)})) 'call System.Console::WriteLine (String)

                .Input(System.IntPtr.Size)
                .Math(JIT.MathOperator.Add) 'add

                .Break.To(lbLoop.Point) 'br.s Label(lbLoop.Point)

                .Break.Mark(lbLoop.Exiter)
                .Pop()
                .Pop()
                .Return()() 'ret; DirectCast(DynamicMethod.CreateDelegate(GetType(DelegateType)), DelegateType)();
            End With
        End With


ISO C++11.NET using ROTOR

$
0
0

Hello,

How would I access free ROTOR to implement an universal bytecode of C++11.NET.

Thanks

Help required on PowerShell CmdLet

$
0
0

I am Prasanna and new to Cmdlet development.

I have to write a cmdlet that takes 4 parameters - A, B, C and D. B is valid only when A is true. And D is valid only if C is true.

I tried to use Dynamic Parameters.

To return 2 different fields depending on A or C, should I write 2 Parameter-classes and return those classes in the call to getDynamicParameters () ?.

Assuming that user specifies both A and C, the method must be made to return both the classes, right ? Is this supported ? How would I make getDynamicParameters() return both ? I derive my CmdLet class from Cmdlet.

Looking for some help on this to support my project-related work at office.

Fixing managed/unmanaged problem

$
0
0

Hello,
I don't know where to post the topic, because it relates mixed applications using unamanged and managed dlls.

A lot of things have been written about loading phase. I cannot find anything about unloading phase.

We had some massive problems during termination phase of our executables.

The problem was that an unmanaged dll (3rd. party!) is using pointers to managed objects

This leads to a crash of the executable, because the unmanaged dll want's to access managed objects during unload of dll.

This has to crash, because of that phase, the CLR has already done its house keeping.

That means the the DLLDetach Code form the 3rd party library is accessing code which can not run anymore.

My understandings is the following for the initialization/deinitilization phase of mixed applications

1. crt is initiliazed

2. crt based variables are initialized (e.g. statics)

3. CLR is intialized

4. CLR base variables are initialized.

For unload it seems to be vice versa

1. CLR is doing house keeping for memory and code

2. CLR is deinitialized/unloaded

3. CRT is doing house keeping for memory and code

4. CRT is unloaded

For a unmanaged DLL (like our 3rd party library :( ), that means that it trys to call e.g. destructors being managed or using managed code. But this exatly happens after the CLR has already done its house keeping . So it crahes.

Workaround:

We found a way to tell that dll to release its internal uses objects, before the exe terminates.
That works, because all runtimes are stille availab.e

But why is Microsoft not fixing the issue.

Here is a proposal hot wo fix it.

Decouple memory house keeping from unlouding the runtimes.

Introduce an additional deinistilization phase which is cleaning the memory, but is not unloading the runtime.

After that phase, after all unmanaged heaps and all managed objects are released,

unload the runtimes.

This ensures that such cross dependent components are able to call there destucturs.

Same is true for initialization

first load both runtimes, than call dll attach and correspondin methods.

Regards

RB

Viewing all 1710 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>