.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan
Asad Ali
Post New Web Links

C++ Q&A: Call Unmanaged DLLs from C#, Killing Processes Cleanly

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net
 

More Related Resource Links

.NET Internals: Examine Running Processes Using Both Managed and Unmanaged Code

  

There are plenty of times when you need to get information on running processes, not the least of which is during performance tuning. Using the techniques in this article and special .NET classes you'll see how to get a process' ID, name, priority, number of threads, kernel handle, and memory consumption, as well as its user-mode, kernel-mode, and total elapsed running time and put them to use in a custom app called AssemblyBrowser.

Christophe Nasarre

MSDN Magazine October 2004


Windows Service crashing on call to unmanaged code, even though console app version works

  

I have a C# program that at some point calls 2 functions from an unmanaged dll using p/invoke.  Everything works fine when I'm running in a console app.  When I compile the same program as a windows service and run it, it crashes.  The console app and service should be identical as far as my code is concerned... all either program does is create an object from another assembly of mine and run a Start() method on it.

I have used VS2010 to debug the managed and unmanaged code, and when I step through the Console app everything looks great.  When I attach the debugger to the service, i can step through the first function in the unmanaged code, control returns to the managed code, and then later when it comes to the point where it calls the second unmanaged function, the process terminates immediately before the debugger steps into the first line of unmanaged code.  There are no exceptions that I can see, and the only thing written to the event log is the generic "service terminated unexpectedly" message.  Running "sc query" on the command line lets me know the win32_exit_code is 1067.

Im running everything in .net 4, on winxp 32bit.  The serivce is running as Local System ideally, but the same behavior exists when I run it under my user account. 

Unmanaged WCF Call Causes StackOverflowException in mscorlib

  

When I call a simple WCF service from a legacy unmanaged application I get a StackOverflowException in mscorlib some time after the call successfully completes in the service and returns to the calling app.  I have recreated the two approaches I use to make the call via dllexports or roughly the approach here:  http://msdn.microsoft.com/en-us/library/ms734731.aspx from a new unmanaged application and both work correctly. 

  The stack overflow occurs at the latest when I exit the application at which point the stack is:

  MyServicesWrapper.dll!<CrtImplementationDetails>::LanguageSupport::DomainUnload(System::Object^ source = 0x03d1f898, System::EventArgs^ arguments = <undefined value>) Line 769 C++
> msvcm80d.dll!<CrtImplementationDetails>::ModuleUninitializer::SingletonDomainUnload(System::Object^ source = 0x03d1f8b8, System::EventArgs^ arguments = <undefined value>) Line 303 + 0x6b bytes C++

and the disassembly looks like this:

000000ca jne 000000D1

000000cc mov eax,dword ptr [ebp-48h]

000000cf jmp 000000DE

000000d1 mov edx,dword ptr [ebp-48h]

000000d4 mo

call JavaScript - jQuery code from ASP.NET Server-Side

  
jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side.

Using jQuery to directly call ASP.NET AJAX page methods

  
Here I am looking to explain how to call page methods using jQuery. Using jQuery to directly call ASP.NET AJAX page methods

call JavaScript - jQuery code from ASP.NET Server-Side

  
jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side

How to call an .exe file in .net

  
Sometimes a developer has to call an EXE from another EXE. While calling EXE there can be a requirement to pass parameter.

Use Unmanaged C++ class in .NET

  

Hi Everyone,


I have one project which is developed in unmanaged C++ code.


Now i want to use all unmanaged classes of C++ in .NET


I have one method called .NET wrapper in which i have to convert Unmanaged C++ class to managed C++ class which will then use as proxy class.

details for that are given in below link.

http://msdn.microsoft.com/en-us/library/aa712980(VS.71).aspx


Is there any other solution for develop this?


CLR Inside Out: Marshaling between Managed and Unmanaged Code

  

Marshaling is an important part of .NET interop. It allows you to call into unmanaged code from managed code. This column will help you get started.

Yi Zhang and Xiaoying Guo

MSDN Magazine January 2008


Web Service Workflows: Deploy Distributed Business Processes With Windows Workflow And Web Services

  

Due to the distributed nature of a business process it makes sense for a workflow to be deployed as a distributed application. See how Windows Workflow and Web Services hold the key.

Israel Hilerio

MSDN Magazine October 2006


C++ at Work: Create Dynamic Dialogs, Satellite DLLs, and More

  

This month Paul DiLascia teaches readers the right way to create dynamic dialogs, explains satellite DLLs and discusses language resource DLLs.

Paul DiLascia

MSDN Magazine September 2006


Call MOM: Instrument and Monitor Your ASP.NET Apps Using WMI and MOM 2005

  

The current version of Windows Management Instrumentation (WMI) satisfies many current and future manageability requirements. In this article Michael Jurek demonstrates how WMI provides important system management capabilities and develops a WMI-aware monitoring solution you can use to instrument your ASP.NET applications. He then introduces the capabilities of MOM 2005 that allow you to monitor these instrumented applications.

Michael Jurek

MSDN Magazine September 2005


What is BPEL4WS?: Build Better Business Processes with Web Services in BizTalk Server 2004

  

In this article the author focuses on one critically important Web services specification that has been largely overlooked: the Business Process Execution Language for Web Services (BPEL4WS, or BPEL). He describes why BPEL is important and what it offers you if you are implementing Web services today or planning to in the future. Concrete examples using BizTalk Server 2004 are presented in the article.

Jon Fancey

MSDN Magazine March 2005


BizTalk 2004: Automate Your Business Processes with Human Workflow Services and Visual Studio

  

BizTalk Server is an excellent platform for automating B2B and EAI workflows. Process-driven workflows send messages between machines and access data. Until now, such processes were very difficult to automate, but with the introduction of Human Workflow Services in BizTalk Server 2004, this class of workflow automation is a very real possibility. This article explains it all.

Chris Whytock

MSDN Magazine October 2004


Coroutines: Implementing Coroutines for .NET by Wrapping the Unmanaged Fiber API

  

Coroutines are a powerful feature of many programming languages including CLU, Scheme, Python, Ruby, and ICON. Coroutines can save processor overhead and reduce redundancy because they allow you to stop execution of a procedure midstream, return a value, and resume exactly where the procedure left off.This article shows how coroutines can be implemented for the .NET Framework by using the Fiber API and Managed Extensions for C++, and how they can be easily used with other .NET-compliant languages. This article also shows a sophisticated use of the runtime host for running multiple managed threads on a single OS thread.

Ajai Shankar

MSDN Magazine September 2003


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend