Building Development and Diagnostic Tools for .Net ForumDiscussion of the APIs and techniques used to build tools for .NET, such as debuggers, profilers, health monitors, compilers, disassemblers, obfuscators etc.© 2009 Microsoft Corporation. All rights reserved.Tue, 24 Nov 2009 19:04:59 Z5634b11a-4477-412c-962b-55073ddd891dhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/7f1d42a1-98c3-4299-b270-00ee116fd09chttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/7f1d42a1-98c3-4299-b270-00ee116fd09ckrt_4tfyhttp://social.msdn.microsoft.com/Profile/en-US/?user=krt_4tfyRewriting equility operator and methods of string class and mscorlib version 2.0.50727.3603<p>I have been happily rewriting mscorlib class methods.  As of the latest build (3603) I have started seeing the following error whenever an ASP.NET application starts up:<br/><br/>Event Type: Error<br/>Event Source: .NET Runtime<br/>Event Category: None<br/>Event ID: 1023<br/>Date:  11/11/2009<br/>Time:  11:28:58 PM<br/>User:  N/A<br/>Computer: LAPTOP<br/>Description:<br/>.NET Runtime version 2.0.50727.3603 - Fatal Execution Engine Error (7A09795E) (80131506)</p> <p>For more information, see Help and Support Center at <a href="http://go.microsoft.com/fwlink/events.asp">http://go.microsoft.com/fwlink/events.asp</a>.<br/><br/>Anyone have ideas about what is going on and what changes are in the new build?</p>Wed, 11 Nov 2009 22:33:07 Z2009-11-24T19:04:59Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/75648433-10e7-45dc-ace8-26b2988baf78http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/75648433-10e7-45dc-ace8-26b2988baf78M.Slavhttp://social.msdn.microsoft.com/Profile/en-US/?user=M.SlavmdMemberRef to a nongeneric delegate nested in a generic type<p>Hi all,<br/>I have the following delegate</p> <pre lang="x-c#">public class GenClass&lt;T, T1, T2&gt; { ... public delegate void MyDelegate(T1 t1, T2 t2, T t); ... }</pre> I use unmanaged Metadata API (IMetaDataImport/IMetaDataEmit) together with Profiling API to rewrite method IL code during JITCompilationStarted stage.  I want to obtain mdMemberRef to Invoke method of MyDelegate. However I am not sure what is the correct way to obtain the reference. Here is what I do:<br/><br/>1) call IMetaDataEmit::DefineTypeRefByName to define ref. to &quot;GenClass`3&quot;<br/>2) call IMetaDataEmit::DefineTypeRefByName to define ref. to &quot;MyDelegate&quot; (passing the token from step 1)<br/>3) construct generic instantiation signature (starting with ELEMENT_TYPE_GENERICINST), lets say one for &lt;object, int, string&gt;<br/>4) call IMetaDataEmit::GetTokenFromTypeSpec with the signature from step 3<br/>5) call IMetaDataEmit::DefineMemberRef with ref. obtained in step 4 and method name set to &quot;Invoke&quot;<br/>6) finally I emit call instruction with the token obtained in step 5<br/><br/>When I try to execute the call to Invoke method I get an error:<br/><br/><strong>Unhandled Exception: System.MissingMethodException: Method not found: 'Void MyDelegate.Invoke(Int32, String, Object)'</strong><br/><br/>Using ILDASM I saw that MyDelegate is actually defined as MyDelegate&lt;T, T1, T2&gt; however there is no backtick symbol (`) in the name.<br/><br/>Can someone explain how I can call &quot;Invoke&quot; method of MyDelegate? Do I have to use IMetaDataEmit2::DefineMethodSpec after step 5?<br/><br/>Any help is appreciated.<br/><br/>TIA, Mihail<br/><br/>Tue, 24 Nov 2009 17:04:56 Z2009-11-24T17:04:57Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/8a090349-ef0c-4f20-ae3e-9617b865eddbhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/8a090349-ef0c-4f20-ae3e-9617b865eddbiam_shivahttp://social.msdn.microsoft.com/Profile/en-US/?user=iam_shiva.Net and Palm (PAD) IntegrationHi,<br/><br/>I need to communicate to .net application with some specific parameters from different palm devices (pdas) and store those parameters in the database.  Could any one tell me a simple solution and how to integrate both the applications.<br/><br/>Thank you in advance.<br/><br/>Kind Regards,<br/>Shiva.Wed, 18 Nov 2009 06:20:57 Z2009-11-24T10:45:18Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/cdf3abba-8b78-4a28-b28b-09a8d5d59bfdhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/cdf3abba-8b78-4a28-b28b-09a8d5d59bfdPRATIK BHADKOLIYAhttp://social.msdn.microsoft.com/Profile/en-US/?user=PRATIK%20BHADKOLIYAHow To Differentiate Different Components (Namespace) in Same Assembly in ProfilerHi,<br/> I am trying to make a custom profiler that gives me information about method call sequence only when i try to call a method of different namespace from current namespace...<br/> Example,<br/> namespace sample<br/> {<br/>     class abc<br/>     {<br/>          public static void Main(String[] args)<br/>          {<br/>               double x = System.Math.Sin(1.5);<br/>               xyz.print(x);<br/>          }<br/>     }<br/>     public class xyz<br/>     {<br/>         public static void print(double x)<br/>         {<br/>                System.Console.WriteLine(x.ToString());<br/>         }<br/>     }<br/> }<br/> <br/> So, in above example when i try to call to method of System.Math (other than sample namespace) then i want information about method enter/exit but if my method call is of diiferent class but same namespace as in case of xyz.print method then i dont want information<br/> <br/> <br/> So, i want to make a profiler that gives me information about all method calls belonging to another namespace..............<br/> Is there any ID that differentiate two namespace as ObjectID and ThreadID that differentiate different class and threads????<br/> <br/> <br/> Thanks in Advance................<br/> <br/>Tue, 03 Nov 2009 16:03:07 Z2009-11-24T04:53:49Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/cf3a440c-9e9a-43e3-b7ad-aa81f32f33a7http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/cf3a440c-9e9a-43e3-b7ad-aa81f32f33a7Monkey.Nethttp://social.msdn.microsoft.com/Profile/en-US/?user=Monkey.NetManaging secondary .net processHi,<br/> <br/> I'm not really sure where to start, so I'm looking for some info to get me going...<br/> <br/> I'm interested in developing an application that manages a secondary application. Preferably it'd work like <br/> <br/> 1. Start application <br/> 2. Before doing anything else, the application invokes a manager process/app/library/whatever<br/> 3. The manager gets information from the application and watches it as it runs, ie, incase it breaks the manager would restart it, return it to some prior state etc...<br/> 4. Should the application fail at some point or a particular event occur then the manager application would step in perform some processing and afterwards return control to the application<br/> <br/> Its all a bit vague at the moment - I think I'm after ideas of how to inject one process into another in .net and then monitor the second process from the first - (or the other way round...)<br/> <br/> Anyway, I'd like to do this in such a way that the application can be developed with next to zero knowledge of the manager and creating the manager in such a way that it is generic enough not to care which application its watching...<br/> <br/> I appreciate the questions a little fluffy. Any starting points would be helpful. Thanks.<br/> <br/> I know how to can catch unhandledexceptions, I'm not looking to load a secondary process using a plugin architecture, I know there's functionality to restart an application but it's not really what I'm after - I think I'm looking to inject one process into another process either when the second process is running or at startup. The idea being that the injected process would provide some custom management/failover/error correcting/reporting of any future application that I write... ie. I'm looking to write my own app to handle the lifecycle of other apps I develop. Any starting points/thoughts/musings are very welcome.<br/> <br/> Cheers<br/>Fri, 20 Nov 2009 16:34:58 Z2009-11-20T18:58:52Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/fbbddd1a-b77a-4ac7-b1e1-b9a74f12143bhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/fbbddd1a-b77a-4ac7-b1e1-b9a74f12143blpszDanhttp://social.msdn.microsoft.com/Profile/en-US/?user=lpszDan.NET 4 process doesn't show up in enumeration<p>Hi Guys and Gals!<br/><br/>So I enumerate all managed processes this way and it shows me asp.net process aspnet_wp.exe for .net 2, but it doesn't show for .net 4. Should I enumberate them differently? <br/>  //30. Create Cor Publisher <br/>  hr = CoCreateInstance( __uuidof( CorpubPublish ), <br/>                                 NULL,<br/>                                 CLSCTX_INPROC_SERVER,<br/>                                 __uuidof( ICorPublish ),<br/>                                 reinterpret_cast&lt; LPVOID * &gt;( &amp;corDebuggerPublisher )<br/>         <br/>         );</p> <p>        //40. Enumerate managed processes<br/>        hr = corDebuggerPublisher-&gt;EnumProcesses( COR_PUB_MANAGEDONLY,<br/>                                                  &amp;activeProcesses<br/>                                                  );<br/>    <br/>Looks like .net 4 creates it's own aspnet_wp.exe, so I see 2 of them in task manager, 1 for v4 and 1 for v2.<br/><br/>Thanks!<br/><br/>Dan</p>Fri, 18 Sep 2009 01:45:01 Z2009-11-12T23:37:38Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/1d27a3a3-34e4-4b0c-8cf6-2ac4d3f384e4http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/1d27a3a3-34e4-4b0c-8cf6-2ac4d3f384e4Nishchalphttp://social.msdn.microsoft.com/Profile/en-US/?user=NishchalpGetting the process detailsI am trying to create a performance monitor for few services. The one provided by OS is very general in nature and shows all the processors and so we wanted to create something that will show just our processes and their details. But when I try to get the details like <span style="font-size:x-small">TotalProcessorTime </span>of a service. it gives me Access Denied Error.<br/><br/>I am administrator of the system and UAC is disabled for the time being.Thu, 12 Nov 2009 21:15:52 Z2009-11-17T09:08:07Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/f600fb33-f9f3-4d07-83d1-51812f1f8cd1http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/f600fb33-f9f3-4d07-83d1-51812f1f8cd1eeimosnhttp://social.msdn.microsoft.com/Profile/en-US/?user=eeimosnDebug Diag OutputI have an application that is increasing its private memory usage over time until eventually it runs out of memory. When the application is shutdown and restart the clock is reset in terms of memory. The fragmentation on the hraddrive also appears to increase. How can I tell from the debug diag output waht is causiong the memory increase...also how can I attach the output to this forum?Tue, 27 Oct 2009 11:04:55 Z2009-11-05T17:15:46Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/ad288cf1-4b7f-4e8b-992b-597cdfea0fadhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/ad288cf1-4b7f-4e8b-992b-597cdfea0fadBitFlipperhttp://social.msdn.microsoft.com/Profile/en-US/?user=BitFlipperVery strange MSIL Disassembler output - this looks like be a bug in ildasm<p>I am disassbling/assembling my C# DLL to make some custom tweaks to the compiled code (to enable reverse P/Invoke, but this is really not relevant to this particular issue). But now I ran into a strange problem when disassembling a C# DLL after it has been compiled. Below is a short snippet of what I see in the IL file right after it has been decompiled. I see the same thing repeated a few times in the IL file. The strange thing is that this only happens sometimes, and if I comment/uncomment various completely unrelated lines of code, I can make it go away/appear. Also, if I add switches like <strong>/source</strong> when disassembling, I can randomly make it work/not work. Very strange. I believe the DLL right after I compile it works, but when I try to decompile it, I get the resulting IL file below (before I even tweak anything). When I try to run ilasm on the output IL file (without making any changes to it), ilasm chokes with a ayntax error on the corrupted lines.<br/><br/>BTW, I am using VS 2008 and .Net 3.5 SP1<br/><br/>Some additional observations after I wrote the above:<br/><br/>- I tried to disassemble the DLL from within the ildasm UI itself, and it works fine.<br/>- I tried to disassemble the DLL using Reflector, and it works fine.<br/><br/>My suspicion is that in the above two cases, the <strong>/linenum</strong> switch is not specified when disassembling the DLL, so they don't run into this problem.<br/><br/>A possible clue might be that there is a problem with the symbol server maybe? The corrupted lines are always right after a statement like <em>class [mscorlib]System.Collections.IEnumerable</em> where it is trying to add the line number. I don't know where ildasm gets the line numbers from for .Net types, and if I can control any of it.<br/><br/>Since this is a showstopper issue for me (my project doesn't run if I can't go through the ildasm/ilasm sequence), I am willing to try anything. One hack I am going to try is when I read the IL file for parsing, is to check whether the line contains any non-ASCII characters, and ignore the whole line if it does. A nasty hack, but what else can I try...?<br/><br/>Any ideas what could be causing the garbled characters?<br/><br/>--------------------------------------------------------------------------<br/><br/>  .method public hidebysig instance class [mscorlib]System.Collections.IEnumerable <br/>          RecordsFrom(class Plugin.Records/Record startRecord,<br/>                      bool forward,<br/>                      bool contiguousPosition,<br/>                      bool contiguousVoice,<br/>                      bool contiguousNote) cil managed<br/>  {<br/>    // Code size       58 (0x3a)<br/>    .maxstack  2<br/>    .locals init ([0] class Plugin.Records/'&lt;RecordsFrom&gt;d__0' V_0,<br/>             [1] class [mscorlib]System.Collections.IEnumerable V_1)<br/>    .line 121,0 : 134218193,0 '??????'????????????????????????????????????????????????????††????›???†††????†??†††??????†††????†?????†††????†????†??????†††????†????†??????†††????†????†??????†††??????'›?????†††????†????†††????†?????††????›???†††??????††??????????????††????›?????†††????†?????††????›???†††???????????????????????????????????????†††????†?????††??????????????††????›???†††???????›??‰??†††????†?????††????›?????††????›???†††???????????????????????????????????†††††††††††††††††††††††††††††††††????????????????††????›??????††????›???†††????†????†??????†††????†????†??????†††????†????†??????†††???????›?????†††????†????†††????†?????††????›????††??????††??????????????††????›?????†††????†???????????†††????'<br/>    IL_0000:  ldc.i4.s   -2<br/>    IL_0002:  newobj     instance void Plugin.Records/'&lt;RecordsFrom&gt;d__0'::.ctor(int32)<br/>    IL_0007:  stloc.0<br/>    IL_0008:  ldloc.0<br/>    IL_0009:  ldarg.0<br/>    IL_000a:  stfld      class Plugin.Records Plugin.Records/'&lt;RecordsFrom&gt;d__0'::'&lt;&gt;4__this'<br/>    IL_000f:  ldloc.0<br/>    IL_0010:  ldarg.1<br/>    IL_0011:  stfld      class Plugin.Records/Record Plugin.Records/'&lt;RecordsFrom&gt;d__0'::'&lt;&gt;3__startRecord'<br/>    IL_0016:  ldloc.0<br/>    IL_0017:  ldarg.2<br/>    IL_0018:  stfld      bool Plugin.Records/'&lt;RecordsFrom&gt;d__0'::'&lt;&gt;3__forward'<br/>    IL_001d:  ldloc.0<br/>    IL_001e:  ldarg.3<br/>    IL_001f:  stfld      bool Plugin.Records/'&lt;RecordsFrom&gt;d__0'::'&lt;&gt;3__contiguousPosition'<br/>    IL_0024:  ldloc.0<br/>    IL_0025:  ldarg.s    contiguousVoice<br/>    IL_0027:  stfld      bool Plugin.Records/'&lt;RecordsFrom&gt;d__0'::'&lt;&gt;3__contiguousVoice'<br/>    IL_002c:  ldloc.0<br/>    IL_002d:  ldarg.s    contiguousNote<br/>    IL_002f:  stfld      bool Plugin.Records/'&lt;RecordsFrom&gt;d__0'::'&lt;&gt;3__contiguousNote'<br/>    IL_0034:  ldloc.0<br/>    IL_0035:  stloc.1<br/>    IL_0036:  br.s       IL_0038</p> <p>    IL_0038:  ldloc.1<br/>    IL_0039:  ret<br/>  } // end of method Records::RecordsFrom<br/><br/>----------------------------------------------------------------------------------</p>Sun, 01 Nov 2009 17:32:38 Z2009-11-20T11:14:27Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/35a1eb58-6e81-42a1-9237-8dce0281dc19http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/35a1eb58-6e81-42a1-9237-8dce0281dc19NSJ SLhttp://social.msdn.microsoft.com/Profile/en-US/?user=NSJ%20SLAssembly generation failed -- Referenced assembly does not have a strong nameI'm getting this error message on compile a .NET solution(3.5) where there is a Class library which is developmed using .NET 1.1. <br/>&quot;Assembly generation failed -- Referenced assembly does not have a strong name&quot;<br/><br/>it uses System.Web.Mail library whic is absolute (warning message).<br/><br/>But this class library individually compiles correctly<br/><br/>Can someone please advice me.<br/><br/>ThxThu, 29 Oct 2009 04:33:06 Z2009-11-06T06:35:48Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/3a821c91-0d8e-486c-8fd6-1a2a85804920http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/3a821c91-0d8e-486c-8fd6-1a2a85804920Dnptdhttp://social.msdn.microsoft.com/Profile/en-US/?user=DnptdThe CLR's internal threadsIt is known that the CLR creates additional threads for its owns needs like GC. Which tasks more may be executed by the CLR except GC? Is there an opportunity to recognize such internal threads inside CLR profiler?<br/><br/>Thanks.Mon, 02 Nov 2009 17:39:05 Z2009-11-06T17:46:43Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/51a20279-5793-4e3f-86ec-2b6092cae93ahttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/51a20279-5793-4e3f-86ec-2b6092cae93aShemoPThttp://social.msdn.microsoft.com/Profile/en-US/?user=ShemoPTMy application uses more and more memory every 5 minuteI have a small chat program. Basic function of the program is that it must connect to server, but if server is not responding he tries to reconnect to server every 25 second. I noised that when server is not responding my chat client is using more and more memory- starting from 4600 kb rises to 38000kb and than gives me an error and shutdowns. <div><br/></div> <div>I am using timer to make application go to Form_load  every 25 second - memory rises. I tried to use application.restart method- memory is not rising but it every 25 second it minimizes everything that is working on PC(because the application restarted.)   </div> <div><br/></div> <div><br/></div> <div>how can I fix such memory rise??</div> <div><br/></div>Tue, 29 Sep 2009 11:40:41 Z2009-11-02T23:39:50Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/f659f2d5-05a3-49a3-8344-21ca2bf583bchttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/f659f2d5-05a3-49a3-8344-21ca2bf583bcGiantBrainhttp://social.msdn.microsoft.com/Profile/en-US/?user=GiantBrainInstrumentation problemUsing .NET profiling, we've discovered that methods can be added to a class during the ModuleAttachedToAssembly callback, but not during the ClassLoadStarted callback. If we try to add a new method during ClassLoadStarted, then references to that method in instrumented code result in Missing Method exceptions from the JIT compiler.<br/> <br/> However, other threads may cause ClassLoadStarted events to be delivered even before we have finished instrumenting a module that contains the class being loaded. This seems to result in a race condition in which the class has been partially instrumented in one thread, but JIT compilation occurs in another thread before the instrumentation is complete.<br/> <br/> Is our observation correct, and if so, is the inability to instrument during ClassLoadStarted a bug? I know that in Java instrumentation, we can instrument a class when we receive a notification from the class loader, so we don't have to instrument unnecessary classes.<br/> <br/> Thanks,<br/> <br/> Bob MeagherTue, 27 Oct 2009 13:08:02 Z2009-11-02T19:40:15Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/1fd8374e-c11f-4073-a877-e4652d13b739http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/1fd8374e-c11f-4073-a877-e4652d13b739lpszDanhttp://social.msdn.microsoft.com/Profile/en-US/?user=lpszDanCurious about x64 .net<p>Is it already supported by VS?<br/>Does it have a separate runtime?<br/>And what's the debugging API for it? So can a 32bit debugger debug 64 bit .net code?<br/>Thanks,<br/>Dan</p>Fri, 30 Oct 2009 02:08:08 Z2009-11-02T17:53:08Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/daaaa2ea-26e1-484c-b122-eac5626c2040http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/daaaa2ea-26e1-484c-b122-eac5626c2040lpszDanhttp://social.msdn.microsoft.com/Profile/en-US/?user=lpszDanHow about in-process debugging?I remember there was an in-process debugging api. <br/>So what are the limitations of in-process debugging and can it even be done?<br/>Thanks<br/>DanFri, 30 Oct 2009 02:17:54 Z2009-11-02T17:42:30Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/c07cc11b-1964-4bfd-b64c-9a55a6d6e986http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/c07cc11b-1964-4bfd-b64c-9a55a6d6e986chickiehttp://social.msdn.microsoft.com/Profile/en-US/?user=chickieCustomer Hardware Requirement for Appz Develop using MS Framework 3.0I got customer encountering slow respond from their machine (old XP) when running my appz.<br/><br/>Appz develop using framwork 3.0 with third party C1 components on some objects which is compiled and deployed.<br/>DB is running Windows Server with SQL 2005 (1GB ram but I don't know the speed server speed).<br/><br/>Question as from the title stated,<br/>do I need to advised my customer to upgrade their machine to 1MB ram with latest cheapest duo core machine?<hr class="sig">Smile, Joshua SiewMon, 26 Oct 2009 02:37:25 Z2009-11-24T04:54:41Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/479cc801-d87a-4c91-ae20-523e5a2104f7http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/479cc801-d87a-4c91-ae20-523e5a2104f7d_m_postolachehttp://social.msdn.microsoft.com/Profile/en-US/?user=d_m_postolachecolors in vbHi guys! <div><br/></div> <div>Is it possible to set the color of a selected date in a monthcalendar?</div> <div>I can find the date that I want but all I can do is to Bold it.</div> <div><br/></div> <div>Thanks a lot</div>Fri, 30 Oct 2009 13:15:08 Z2009-11-06T06:16:37Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/c67dd232-1092-4ec3-b1bd-8e50a395d29ehttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/c67dd232-1092-4ec3-b1bd-8e50a395d29ehorseman_uahttp://social.msdn.microsoft.com/Profile/en-US/?user=horseman_uaStrange behaivour of process countersHi, All!<br/> <br/> We have web application in which we are using some performance counters. For cases when there are more then one application run simultaneously we have code for determining current instance name:<br/> <pre lang="x-c#"> int processId = GetProcessID(); PerformanceCounterCategory processCategory = new PerformanceCounterCategory(&quot;Process&quot;); string[] runnedInstances = processCategory.GetInstanceNames(); foreach (string runnedInstance in runnedInstances){ using (System.Diagnostics.PerformanceCounter performanceCounter = new System.Diagnostics.PerformanceCounter(&quot;Process&quot;, &quot;ID Process&quot;, runnedInstance, true)){ if ((int)performanceCounter.RawValue == processId){ return runnedInstance; } } }</pre> This code works fine but some time ago we added in our support of two counters from .Net CLR category. And as we discovered they have different match between process id and instance name: <a href="http://img26.imageshack.us/img26/9876/perfmon.png">illustrated here</a> <br/> <br/> So Process Id's are differs for one instance name for .Net Clr Memory and Process category.<br/> <br/>    1. Is it bug of .Net?<br/>    2. What counter(Process ID from .Net Clr Memory or ID Process from Process category) should I use to get right Instance name?Tue, 27 Oct 2009 10:16:18 Z2009-10-27T15:24:52Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/5df6d1c8-dc7a-438f-b0e3-c86444c5a82chttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/5df6d1c8-dc7a-438f-b0e3-c86444c5a82clpszDanhttp://social.msdn.microsoft.com/Profile/en-US/?user=lpszDanHow does .NET find dlls corresponding to namespaces it imports?<p>I type in code <br/>Imports this.and.this<br/>but how does it know what dll to load? Is it registered somewhere?<br/>How could I know if that namespace is available on my machine?<br/>Thanks<br/>Dan</p>Sun, 25 Oct 2009 08:18:22 Z2009-10-30T10:10:12Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/fbe409c8-0b2f-4971-bfbf-f7514beba517http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/fbe409c8-0b2f-4971-bfbf-f7514beba517lpszDanhttp://social.msdn.microsoft.com/Profile/en-US/?user=lpszDanIs there a way to enumerate current variables from within the C# itself?<p>All those System.Reflection and metadata apis included in .NET made me wonder, <br/>is it possible for a program code to just enumerate or get access from within itself to a list of all <br/>local variables or to a hierarchy of scopes with variables up to the global one?</p>Wed, 21 Oct 2009 04:57:52 Z2009-10-27T09:54:33Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/1c9c73ba-1b4b-46eb-a7e4-9d0ee04f0736http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/1c9c73ba-1b4b-46eb-a7e4-9d0ee04f0736austinwanghttp://social.msdn.microsoft.com/Profile/en-US/?user=austinwangCan't debug in VS2005 after IE8.0 upgradeAny one know why I can't use debug in vs2005 after ie8 upgrade? Thank you.Wed, 21 Oct 2009 04:54:44 Z2009-10-26T06:47:38Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/2adf7137-77ca-4e50-ba6d-38cd2b13414bhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/2adf7137-77ca-4e50-ba6d-38cd2b13414bHaripraghashhttp://social.msdn.microsoft.com/Profile/en-US/?user=HaripraghashHow to use CLR profiler to evaluate the performance of WCF service hosted in IIS?Hi,<br/> <br/> Is it possible to evaluate the performance of a WCF service hosted in IIS using CLR profiler?Sat, 17 Oct 2009 15:37:19 Z2009-10-23T08:16:26Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/ee0a528c-8f4a-4008-856b-29cfb19ce7fchttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/ee0a528c-8f4a-4008-856b-29cfb19ce7fcABroadbenthttp://social.msdn.microsoft.com/Profile/en-US/?user=ABroadbentIgnoring accessibility levelsHey, currently I'm writing unit tests for a large project, and a problem has occured.  I need to test private, protected and internal classes in the project assembly, but I need to do it from a seperate assembly.<br/> <br/> The reasoning for this is, I don't want the project assembly to contain unit tests, as it will be being released to end users, but more importantly I don't want them there as  they will effectivly double the size of each project, making loading and linking times considerable longer.<br/> <br/> is there a way that I can get my test assembly to ignore the accessibility level system in the project assembly, without changing code in the project assembly?  If not, is there another way around this problem?<br/> <br/> Thanks fo any help,<br/> AndyWed, 30 Sep 2009 10:26:52 Z2009-10-13T17:06:39Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/5922e4f9-1065-4f2a-b2bb-b18a0805a651http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/5922e4f9-1065-4f2a-b2bb-b18a0805a651NewToWindowshttp://social.msdn.microsoft.com/Profile/en-US/?user=NewToWindowsNeed Information on .NET Usage and LicensingHi ...to all,<br /> I am not sure weather i am posting this question in right Category.<br /> I am very much new to windows application development. In fact I am a developer in Linux platform(QT&amp;GTK). Now i want to develope a commercial (closed source) desktop application in windows using .NET framework. First of all my sincere apologies for asking such a simple/basic/stupid questions. I couldn't found exact answers. My questions are simple and straight<br /> 1)Will Microsoft charge any fee(licensing fee) for developing commercial desktop application on windows. i.e. should i pay&nbsp; to Microsoft for downloading .NET SDK and run time libraries.?<br /> 2)Should my customers have to pay any fee for installing .NET environment on their systems in order to run my application.?<br /> 3)Is .NET is free for developers like me?( as i want to develop commercial closed source apps &amp; i will charge my customers for getting my application)<br /> 4)Can you please give me the END to END procedure for developing such commercial apps on windows <br /> <br /> Thank you in advance for you patience. I hope you will encourage people like me who wants to shift from open source community.Sat, 10 Oct 2009 16:51:33 Z2009-10-12T11:25:56Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/bba15abe-b501-4c0a-a72c-ac2863337497http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/bba15abe-b501-4c0a-a72c-ac2863337497MishaSofthttp://social.msdn.microsoft.com/Profile/en-US/?user=MishaSoftCreating Performance Counter Logs using C#<span>  <p>Hey,</p> <p> </p> <p>I hope that I'm posting my question in the correct place.</p> <p> </p> <p>I'm developing an application that should sample certain Performance Counters with </p> <p>predefined frequency and save results to the Log file. </p> <p>Windows allows to create, configure and run Counter Logs using mmc.</p> <p>I've spent a lot of time looking for an API that allows to interact with this feature</p> <p>programatically and haven't found anything.</p> <p> </p> <p>Is there any way to create/manage these Performance Counters Logs using C# </p> <p>or any Win32 unmanaged API ?</p> <p> </p> <p>Thanks.</p> <p> </p> <p>P.S. Sorry for my English</p><span></span></span>Thu, 12 Jul 2007 05:06:27 Z2009-10-12T11:15:19Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/c8819210-3080-4cae-95d1-1e4ff1a67229http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/c8819210-3080-4cae-95d1-1e4ff1a67229lpszDanhttp://social.msdn.microsoft.com/Profile/en-US/?user=lpszDanAny info on debugging a process dump after it's crashed?<p>I heard .net support or will support a kind of debugging when the process just dumps everything into a log and you can just step through it and see what happened after the fact.<br/>Any info on that?<br/>Thanks<br/>Dan</p>Sat, 26 Sep 2009 02:00:04 Z2009-11-04T21:40:11Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/fbe08ed5-cf95-435d-945b-0f84fff94a18http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/fbe08ed5-cf95-435d-945b-0f84fff94a18lpszDanhttp://social.msdn.microsoft.com/Profile/en-US/?user=lpszDanIs there a way to set a breakpoint when variable changes?This got me curious.<br/>Is there a way to set a breakpoint when a variable changes? Any code samples for that?<br/>Thanks.<br/>DanSat, 26 Sep 2009 02:01:15 Z2009-10-01T00:02:57Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/0220f50b-4636-4873-8b1e-b364f34c2502http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/0220f50b-4636-4873-8b1e-b364f34c2502JulianRosshttp://social.msdn.microsoft.com/Profile/en-US/?user=JulianRossCLR Profiler and Finalize (GC)Hi! I've a question about development a CLR Profiler. <div><br/></div> <div>Is possible the finalize method is called after the end of main?</div> <div><br/></div> <div> <div>time=[02:36:23:546], LEAVE, stack_size=1, thread=1431368, Test.Program::Main, static void (String[]), id=9580584, object_id=0, call_count=1, class_id=9580608, module_id=9579580 </div> <div>time=[02:36:23:546], ENTER, stack_size=0, thread=1505064, Test.Class_A::Finalize, void (), id=9580728, object_id=23805820, call_count=1, class_id=9580772, module_id=9579580</div> <div>time=[02:36:23:546], LEAVE, stack_size=1, thread=1505064, Test.Class_A::Finalize, void (), id=9580728, object_id=23805820, call_count=1, class_id=9580772, module_id=9579580 </div> <div>time=[02:36:23:546], ENTER, stack_size=0, thread=1505064, Test.Class_A::Finalize, void (), id=9580728, object_id=23796676, call_count=2, class_id=9580772, module_id=9579580 </div> <div>time=[02:36:23:546], LEAVE, stack_size=1, thread=1505064, Test.Class_A::Finalize, void (), id=9580728, object_id=23796676, call_count=2, class_id=9580772, module_id=9579580</div> <div><br/></div> <div>Is it correct?</div> <div><br/></div> </div> <div><br/></div> <div><br/></div>Fri, 25 Sep 2009 23:11:02 Z2009-10-06T04:17:06Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/fab99853-6d53-4f82-80bf-fcf2a3177bafhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/fab99853-6d53-4f82-80bf-fcf2a3177bafintripoonhttp://social.msdn.microsoft.com/Profile/en-US/?user=intripoonHow to get a full stacktrace from a crashed mixed mode exe/dll ?<div class=post-text> <p>Hi !</p> <p>I wrote an application in C++/CLR. It uses a native lib/dll. On rare occasions, it crashes insider this native dll. I then get a stacktrace, but only up to the managed part, the inside native part is left out. Is there a way to let it display the whole stacktrace?</p> <p>I made the following test: I added a line of code inside the native dll that makes it always crash. When I run it by doubleclicking the exe, I get a stacktrace of the managed part like before. If I run it from VS2008 with a debugger attached (just pressing F5), and it crashes, I see the whole stacktrace, the managed and the unmanaged parts.</p> <p>Since the actuall bug happens so rarely, I'ld like to add something to my application that somehow displays the whole stacktrace without having the users to install und run it through VS. Is there a way to do that?</p> <p>Thx</p> <p>    Marc</p> </div>Tue, 22 Sep 2009 16:34:19 Z2009-10-05T02:43:15Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/a54353cd-6320-4f7b-9f03-782b7ba789e9http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/a54353cd-6320-4f7b-9f03-782b7ba789e9srinivasvinnakotahttp://social.msdn.microsoft.com/Profile/en-US/?user=srinivasvinnakotaHow to filter Calltree in CLR profiler to show calls from only my DLLs and Exe?<span id="_ctl0_MainContent_PostFlatView"><span>This is a question on CLRProfiler's CallTree feature. How do I make the CLR profiler's calltree display to display only function calls from (and to) my dlls and executables? In otherwords I am not interested in seeing functions from System dlls and other .Net dlls, I want to see <span style="font-weight:bold">only my code's functions. </span><br style="font-weight:bold"><br style="font-weight:bold">Note that the CLR profiler &quot;CallTree&quot; is different from the call tree (or call graph) display some other profilers display, such as RedGate ANTS profiler; or even the Visual Studio Team system's profiler call graph. These displays are sorted by the amount of time taken for the functions to execute, not in the chronological order of execution. I need <span style="font-weight:bold">CHRONOLOGICAL ORDER OF FUNCTION CALLS. </span>There is a lot of documentation and forums and threads that discuss the performance-sorted call graph, that is of no use to me.<br><br>Any help is greatly appreciated. Thanks in advance. </span></span> Tue, 07 Oct 2008 16:57:09 Z2009-09-24T12:36:52Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/69758f56-155d-4305-8c0b-6575a07d00e2http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/69758f56-155d-4305-8c0b-6575a07d00e2gattaccio7http://social.msdn.microsoft.com/Profile/en-US/?user=gattaccio7Profiler: find out ThreadID and ObjectID<br/> Hi,<br/> <br/> I'm writing a .net profiler using the ICorProfilerCallback2 interface.<br/> I'd like to obtain this informations when an event, like FuncionEnter or FuncionLeave, occurs.<br/> <br/> Assuming to use a callback function with a COR_PRF_FUNCTION_ARGUMENT_INFO *argumentInfo parameter,<br/> I get the ObjectID  as the first implicit parameter of a non-static method in this way:<br/> ObjectID id = static_cast&lt;ObjectID&gt;(argumentInfo-&gt;ranges[0].startAddress);<br/> Is it correct?<br/> And when the method is static, where I can find this information?<br/> <br/> Moreover, I need to know the function ThreadID, i.e. the ID of the running thread of the profiled <br/> application that called the function. How can I do?<br/> <br/> <br/> Thank you everyone, FabrizioTue, 31 Mar 2009 16:29:21 Z2009-09-24T11:17:11Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/1620b6e5-fe96-4c8f-b58b-9567f1fd2c9fhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/1620b6e5-fe96-4c8f-b58b-9567f1fd2c9fBorgdylanhttp://social.msdn.microsoft.com/Profile/en-US/?user=BorgdylanXML Documentation for Reflecion EmitIs it possible to generate XML documentation from assemblies made using reflection emit. VB and C# can do it. Is this feature inside the reflection classes?.Sun, 13 Sep 2009 16:00:28 Z2009-09-22T15:27:04Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/b974a659-810d-4fc1-b3cb-ba2dfa4afc53http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/b974a659-810d-4fc1-b3cb-ba2dfa4afc53lpszDanhttp://social.msdn.microsoft.com/Profile/en-US/?user=lpszDanHow are modules and assemblies related?<p>So an assembly is like a dll, right and what is a module? Is it like a source code file wthin an assembly?</p>Fri, 18 Sep 2009 02:13:46 Z2009-09-18T23:23:18Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/fef06f1d-fb87-4554-b8d5-7905173132cfhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/fef06f1d-fb87-4554-b8d5-7905173132cfAmitGhttp://social.msdn.microsoft.com/Profile/en-US/?user=AmitGIdentifying memory usage using WindbgHi, <div><br/></div> <div>I'm trying to identify why my application takes up nearly 1GB of memory. According to CLR profiler (and .NET memory profiler) all the managed objects only add up to around 200MB-ish. I took a dump using WinDbg and here's the output I get from !address - summary</div> <div><br/></div> <div> <pre>0:000&gt; !address -summary -------------------- Usage SUMMARY -------------------------- TotSize ( KB) Pct(Tots) Pct(Busy) Usage 3191d000 ( 812148) : 38.73% 54.48% : RegionUsageIsVAD 25026000 ( 606360) : 28.91% 00.00% : RegionUsageFree 11afc000 ( 289776) : 13.82% 19.44% : RegionUsageImage 4600000 ( 71680) : 03.42% 04.81% : RegionUsageStack 46000 ( 280) : 00.01% 00.02% : RegionUsageTeb 13567000 ( 316828) : 15.11% 21.25% : RegionUsageHeap 0 ( 0) : 00.00% 00.00% : RegionUsagePageHeap 1000 ( 4) : 00.00% 00.00% : RegionUsagePeb 1000 ( 4) : 00.00% 00.00% : RegionUsageProcessParametrs 2000 ( 8) : 00.00% 00.00% : RegionUsageEnvironmentBlock Tot: 7fff0000 (2097088 KB) Busy: 5afca000 (1490728 KB) -------------------- Type SUMMARY -------------------------- TotSize ( KB) Pct(Tots) Usage 25026000 ( 606360) : 28.91% : &lt;free&gt; 14ae5000 ( 338836) : 16.16% : MEM_IMAGE 1129000 ( 17572) : 00.84% : MEM_MAPPED 453bc000 ( 1134320) : 54.09% : MEM_PRIVATE -------------------- State SUMMARY -------------------------- TotSize ( KB) Pct(Tots) Usage 44ad5000 ( 1125204) : 53.66% : MEM_COMMIT 25026000 ( 606360) : 28.91% : MEM_FREE 164f5000 ( 365524) : 17.43% : MEM_RESERVE Largest free region: Base 570f8000 - Size 03c78000 (61920 KB) </pre> <br/></div> <div>I'm pretty new to Windbg but I can tell that the .NET allocated memory (in RegionUsageIsVAD) is around 800MB and the native (which I presume is RegionUsageHeap) is around 300 MB. Can someone point me in the right direction, based on this?</div> <div><br/></div> <div>Thanks,</div> <div>Amit</div> <div><br/></div>Fri, 17 Jul 2009 11:41:41 Z2009-09-17T16:33:46Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/153577d6-006b-40b5-820e-ee16397d6d92http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/153577d6-006b-40b5-820e-ee16397d6d92SureshtheCTAhttp://social.msdn.microsoft.com/Profile/en-US/?user=SureshtheCTACLRProfiler - Relocated Bytes not updated on induced collections?Hi,<br/>    I am trying to understand Clr Profiler, and below is the sample code.<br/>             <br/>             EmployeeService e = new EmployeeService();<br/> <br/>             GC.Collect();<br/>             //Console.WriteLine(GC.GetGeneration(e).ToString());<br/> <br/>             Thread.Sleep(1000);<br/>             GC.Collect();<br/> <br/> <br/>        So i assume EmployeeService will be allocated at gen 0 first, as part of two induces collections it should have been moved to Gen 2. But the 'Relocated Bytes' shows 0, why is that? Please help.<hr class="sig">SureshMon, 14 Sep 2009 16:02:44 Z2009-09-21T16:01:34Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/38550e3e-6d6a-4aad-a5e4-57873f340238http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/38550e3e-6d6a-4aad-a5e4-57873f340238Borgdylanhttp://social.msdn.microsoft.com/Profile/en-US/?user=BorgdylanWhat info can be added to debug symbols in addition to local variables and source lines?<span style="font-family:'Calibri','sans-serif';font-size:11pt">I am Dylan Borg from the tiny European island of Malta. I am building a compiler for the Dylan.NET language currently in v. 7.3. I have read your blog and managed to make pdb files associated with the assemblies. I also managed to use DbgClr.exe from the .NET 2.0 SDK to debug, step into and set breakpoints with dy;an.NET source files and binaries after the compiler made the binaries and program debug files. I wanted to know how to write symbol info for elements other than local variables and source code lines. Is there a way to write info for fields, method parameters etc. The current dylan.NET sources and binaries(before the debug support) with documentation can be found at <a href="http://dylandotnet.codeplex.com/">http://dylandotnet.codeplex.com/</a> and <a href="http://borgdylan.web.officelive.com/dylandotnet.aspx">http://borgdylan.web.officelive.com/dylandotnet.aspx</a> .</span>Sat, 12 Sep 2009 07:06:59 Z2009-09-14T16:01:20Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/ae65e66e-02d6-4e43-9d53-6bb9aaef2e6chttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/ae65e66e-02d6-4e43-9d53-6bb9aaef2e6cBorgdylanhttp://social.msdn.microsoft.com/Profile/en-US/?user=BorgdylanAdding brekpoints to Reflection Emit Generated FilesHi there I am Dylan Borg from Malta. I am building a compiler for the dylan.NET language and managed to make my generated code debuggable. The pdb files are also made. But how fo I put breakpoints etc. In mdbg you cannot step into a p[rocess that has finished executing. If there is no exception thrown the debugger does not stop the process. Is there a way in mdbg or in reflection emit to make the program stop at a specific line.Fri, 11 Sep 2009 09:25:29 Z2009-09-11T18:04:29Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/865c9f86-5da5-4e10-870c-ed17c17b9c74http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/865c9f86-5da5-4e10-870c-ed17c17b9c74PaulGreyhttp://social.msdn.microsoft.com/Profile/en-US/?user=PaulGreySetting breakpoints in ntsd<p>Hi,<br/><br/>I'm trying to get into using ntsd and so I'm new to this debugging environment.<br/>To get started, I'm trying to set the below class with a breakpoint on the Main method.<br/><br/><em>using System;<br/>public class sample<br/>{<br/>    static void Main()<br/>    {<br/>         Console.WriteLine(&quot;Hello world&quot;);   <br/>     }<br/>}</em><br/><br/>So I compile the class:<br/>csc /debug .\App.exe<br/><br/>Then invoke the debugger:<br/>ntsd .\App.exe<br/><br/>Then i setup the debugging:<br/>.symfix<br/>.reload<br/>sxe ld mscorwks<br/>g<br/>.loadby sos mscorwkk<br/><span style="font-family:'Courier New';font-size:10pt"><strong>!bpmd App.exe sample.Main</strong><br/></span>g<br/><br/>When I set the breakpoint I get a messsage saying 'Adding pending breakpoints' but the breakpoint never hits and the program executes right through.<br/>Any help would be really appreciated.<br/><br/>Thanks,<br/>Paul<br/></p>Fri, 14 Aug 2009 12:23:09 Z2009-11-04T14:45:26Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/0c93d8e3-42db-4cca-ba96-d3fb3d251e74http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/0c93d8e3-42db-4cca-ba96-d3fb3d251e74Yitaohttp://social.msdn.microsoft.com/Profile/en-US/?user=YitaoExecutionEngineException while profiling mscorlib methodHi,<br/> <br/>   I'm testing a byte-code rewriting profiler that would prefix some methods with a call into an empty class/stub in an external GAC-ed assembly.  This profiler fails quickly in ASP.NET when it modifies methods inside mscorlib.  In this case, I'm modifying only overloaded constructors for System.Collections.Queue.  The prefixed call is done by creating an assemblyRef/typeRef/memberRef to the external assembly.  The external assembly has been reduced to a single class with only static/void/empty methods.  This also means the external assembly has no additional dependencies.  The exception occurs during AppDomain construction.  Is implicitly loading of external assemblies prohibited at particular points in the CLR/AppDomain loading process?  If not, what is the problem here?  The profiler works great for classes NOT in mscorlibs.<br/> <br/> The Event Viewer shows an internally caught System.ExecutionEngineException.  <br/> <br/> <span style="text-decoration:underline"><strong><br/> CLR exception</strong> </span> <br/> <br/> <br/> <pre>Exception object: 180a451c Exception type: System.IO.FileLoadException Message: Could not load file or assembly 'my.external, Version=1.0.0.0, Culture=neutral, PublicKeyToken=somepublickey' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) InnerException: &lt;none&gt; StackTrace (generated): &lt;none&gt; StackTraceString: &lt;none&gt; HResult: 80070057 </pre> <span style="text-decoration:underline"><strong><br/> The CLR stack</strong> </span> <br/> <br/> <br/> <pre>OS Thread Id: 0x2a6c (17) ESP EIP 0279d4a0 7d61002d [GCFrame: 0279d4a0] 0279d52c 7d61002d [GCFrame: 0279d52c] 0279e50c 7d61002d [PrestubMethodFrame: 0279e50c] System.Collections.Queue..ctor() 0279e51c 04549606 System.Runtime.Remoting.RemotingConfigHandler..cctor() 0279e8b0 79e7c74b [GCFrame: 0279e8b0] 0279ee18 79e7c74b [PrestubMethodFrame: 0279ee18] System.Runtime.Remoting.RemotingConfigHandler.get_UrlObjRefMode() 0279ee28 045495a6 System.Runtime.Remoting.ObjRef.ShouldUseUrlObjRef() 0279ee2c 04545555 System.Runtime.Remoting.ObjRef.Init(System.Object, System.Runtime.Remoting.Identity, System.Type) 0279ee5c 0454534c System.Runtime.Remoting.ObjRef..ctor(System.MarshalByRefObject, System.Type) 0279ee70 0454528c System.MarshalByRefObject.CreateObjRef(System.Type) 0279ee80 045436f1 System.Runtime.Remoting.RemotingServices.MarshalInternal(System.MarshalByRefObject, System.String, System.Type, Boolean) 0279eed4 04543531 System.Runtime.Remoting.RemotingServices.CreateDataForDomainCallback(System.Object[]) 0279eee0 045434e8 System.Threading.Thread.CompleteCrossContextCallback(System.Threading.InternalCrossContextDelegate, System.Object[]) 0279f0dc 79e7c74b [ContextTransitionFrame: 0279f0dc] 0279f0a4 79e7c74b [HelperMethodFrame_PROTECTOBJ: 0279f0a4] System.Threading.Thread.InternalCrossContextCallback(System.Runtime.Remoting.Contexts.Context, IntPtr, Int32, System.Threading.InternalCrossContextDelegate, System.Object[]) 0279f1ac 04541232 System.Runtime.Remoting.RemotingServices.CreateDataForDomain(Int32, IntPtr) 0279f1bc 0454119f System.Runtime.Remoting.RemotingServices.CreateProxyForDomain(Int32, IntPtr) 0279f48c 79f5e350 [HelperMethodFrame_PROTECTOBJ: 0279f48c] System.AppDomain.nCreateDomain(System.String, System.AppDomainSetup, System.Security.Policy.Evidence, System.Security.Policy.Evidence, IntPtr) 0279f500 03fcd197 System.AppDomain.CreateDomain(System.String, System.Security.Policy.Evidence, System.AppDomainSetup) 0279f51c 03fca55e System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(System.String, System.Web.Hosting.IApplicationHost, System.Web.Hosting.HostingEnvironmentParameters) 0279f59c 03fca38f System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironmentAndReportErrors(System.String, System.Web.Hosting.IApplicationHost, System.Web.Hosting.HostingEnvironmentParameters) 0279f5d8 03fca20c System.Web.Hosting.ApplicationManager.GetAppDomainWithHostingEnvironment(System.String, System.Web.Hosting.IApplicationHost, System.Web.Hosting.HostingEnvironmentParameters) 0279f628 03fca036 System.Web.Hosting.ApplicationManager.CreateObjectInternal(System.String, System.Type, System.Web.Hosting.IApplicationHost, Boolean, System.Web.Hosting.HostingEnvironmentParameters) 0279f648 030fdd7f System.Web.Hosting.AppManagerAppDomainFactory.Create(System.String, System.String) 0279f898 79f047fd [GCFrame: 0279f898] 0279f9f4 79f047fd [ComMethodFrame: 0279f9f4] </pre> <br/> <span style="text-decoration:underline"><strong>Native stack</strong> </span> <br/> <br/> <br/> <pre>ChildEBP RetAddr 0279cf24 7a1060b3 ntdll!DbgBreakPoint 0279d3d4 7a10624f mscorwks!EEPolicy::LogFatalError+0x2b5 0279d3ec 79f071c7 mscorwks!EEPolicy::HandleFatalError+0x36 0279d44c 7a10733d mscorwks!RaiseTheExceptionInternalOnly+0x2c3 0279d464 7a1073b1 mscorwks!RaiseTheException+0x4e 0279d48c 7a1073e2 mscorwks!RaiseTheException+0xc0 0279d4b8 7a1073f0 mscorwks!RealCOMPlusThrow+0x30 0279d4c8 7a010c38 mscorwks!RealCOMPlusThrow+0xd 0279d5b8 79f112e4 mscorwks!CEEInfo::findMethodInternal+0x3ae 0279d638 79061fd6 mscorwks!CEEInfo::findMethod+0x107 0279d650 7906535a mscorjit!Compiler::eeFindMethod+0x22 0279d720 79063324 mscorjit!Compiler::impImportCall+0xa7 0279dcf8 790635c3 mscorjit!Compiler::impImportBlockCode+0x29ae 0279dd7c 7906355b mscorjit!Compiler::impImportBlock+0x20c 0279dd94 79063494 mscorjit!Compiler::impImport+0xe5 0279dda0 79064e1c mscorjit!Compiler::fgImport+0x20 0279ddac 790614e6 mscorjit!Compiler::compCompile+0xb 0279de04 79061236 mscorjit!Compiler::compCompile+0x2df 0279de98 7906118c mscorjit!jitNativeCode+0xb8 0279ded0 79f0f9cf mscorjit!CILJit::compileMethod+0x3d </pre> <br/> <br/>Tue, 08 Sep 2009 18:42:19 Z2009-09-09T05:20:12Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/bcd72214-c0f5-4904-ba06-9e6d90bc5651http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/bcd72214-c0f5-4904-ba06-9e6d90bc5651S. Skovhttp://social.msdn.microsoft.com/Profile/en-US/?user=S.%20SkovMetaData API and Generic parametersGreetings,  <div><br/></div> <div> I have run into an issue getting the type of a generic parameter using the MetaData API. </div> <div><br/></div> <div> When parsing the signature of a method with generic parameters and generic arguments, which is defined in a class with <em>different</em> generic parameters, I run into some troubled waters when I get to the ELEMENT_TYPE_VAR of the generic type. The 'docs' state that the next segment of the signature defines an index - but I don't see anywhere how to use this index to lookup the type precisely - i.e. is the index part of the methods generic parameters or the defining class generic parameters.</div> <div><br/></div> <div>An example:</div> <div><br/></div> <div>Say I have a C# class like so:</div> <div><br/></div> <div> <div>class GenericClass&lt;TClass, SClass, PClass&gt;</div> <div>{</div> <div>        public void GenericMethod&lt;UMethod, RMethod&gt;(SClass SomeArg, RMethod SomeOtherArg)</div> <div>        {</div> <div>            </div> <div>        }</div> <div>}</div> </div> <div><br/></div> <div> When parsing the signature and getting to the SClass SomeArg argument I get an index of 1 from the signature - but how do I figure out where this 1 belongs - the class (as is the case) or the method ?</div> <div><br/></div> <div> From studying the SSCLI implementation of ILDASM I can see that it depends on an internal interface (IMDInternalImport) to make the distinction - anything similar in non-internal land or are there any other methods of doing this (have to be unmanaged - non reflection). </div> <div> </div> <div>Regards,</div> <div><br/></div> <div>Skov</div>Fri, 04 Sep 2009 21:08:56 Z2009-09-09T00:44:22Z