|
|
|
date: Wed, 7 Jun 2006 17:04:11 -0400,
group: microsoft.public.platformsdk.internet.server.isapi-dev
back
Re: ISAPI Extension calling managed code
Hi and thanks Ian,
I had posted last month, perhaps further back than that, and David briefly
mentioend "yes" this is valid and instructed to go research/find the
solution.
I believe that I have truly exhausted all of the resources available to me
and have not pinpointed a solution for this simple excercise.
I am very far beyond a good starting point, the example is quite concise and
the goal of an native ISAPI extension instantiating a managed module is
highlighted. The code is a VS2005 solution, targeted for IIS6+.
I think, what remains is an simple answer like an additional compiler/linker
switch or perhaps an alternative construction/timing approach. It'll likely
cause me to hit my head on the desk :) but that's ok, it is already dented.
That is why I am calling on the community, if maybe someone could take a
peak and solve, perhaps we can get this clarified?
Thanks,
- Mike
> Not sure if there is a Part 2 yet but this is probably going to be a good
> place to start looking for information.
>
> I don't know much about .NET and mixing code but I suspect the most likely
> way of getting it to "work" is by using a pure C/C++ ISAPI extension which
> starts a process with the .NET code in and connects to it via a named
> pipe. The feasibility of this approach really depends on what you are
> trying to achieve.
>
> Ian
>
>
date: Thu, 8 Jun 2006 09:48:00 -0400
author: mike
Re: ISAPI Extension calling managed code
Hello
I have developed a .net remoting client -server application. And i am
hosting my server on iis 6.0 on windows 2003, and i have written the
authentication filter using vc++ for login mechanisam, both works fine
indivisually but when i integrate with each other means i use both in
the same application , it will work some time and some time it hang up.
Can anyone knows the cause of this
Thanks
Satish Thumar
mike wrote:
> Hi and thanks Ian,
>
> I had posted last month, perhaps further back than that, and David briefly
> mentioend "yes" this is valid and instructed to go research/find the
> solution.
>
> I believe that I have truly exhausted all of the resources available to me
> and have not pinpointed a solution for this simple excercise.
>
> I am very far beyond a good starting point, the example is quite concise and
> the goal of an native ISAPI extension instantiating a managed module is
> highlighted. The code is a VS2005 solution, targeted for IIS6+.
>
> I think, what remains is an simple answer like an additional compiler/linker
> switch or perhaps an alternative construction/timing approach. It'll likely
> cause me to hit my head on the desk :) but that's ok, it is already dented.
>
> That is why I am calling on the community, if maybe someone could take a
> peak and solve, perhaps we can get this clarified?
>
> Thanks,
>
> - Mike
>
> > Not sure if there is a Part 2 yet but this is probably going to be a good
> > place to start looking for information.
> >
> > I don't know much about .NET and mixing code but I suspect the most likely
> > way of getting it to "work" is by using a pure C/C++ ISAPI extension which
> > starts a process with the .NET code in and connects to it via a named
> > pipe. The feasibility of this approach really depends on what you are
> > trying to achieve.
> >
> > Ian
> >
> >
date: 8 Jun 2006 22:00:21 -0700
author: unknown
Re: ISAPI Extension calling managed code
I recently built an ISAPI filter that was "mixed mode", I wrap it in quotes
because I did not mark the project as mixed mode. Instead I wrote the filter
as an unmanged DLL, then I marked specific classes as using the framework.
Essentially you only enalbe the /clr flag on the individual source files
that are .NET enabled but leave the project settings alone.
The caveat to this technique is that it is difficult to pass pointers
between the pure unmanaged classes and the .NET classes. Whenever an
unmanaged class needs to retain a pointer to a managed class, you have to
use GCHandles to hold the pointers.
the filter loads fine and access the 2.X .net framework, which in turn can
load and unload C# assemblies.
"mike" wrote in message
news:O$yILYniGHA.4140@TK2MSFTNGP03.phx.gbl...
> Hi,
>
> I have been wrestling with this for some time now and am not finding the
> solution for ISAPIs. I've seen articles that address DllMain to prevent
> locking but with ISAPI, things at this point simply fault.
>
> Attached is a very simple ISAPI Extension (MixedIsapi.dll derived from
> Wade's HelloIsapi.dll in the IIS SDK) that instantiates a very simple
> class. The class is in a separate module file and the file's properties
> are configured for compilation with clr and the other appropriate
> switches/settings. That is... at least appropriate enough to compile, link
> and <partially> run.
>
> The same effort and settings within the MixedConsole has helped as a
> sanity check, however the Console solution also supports that an exe
> behaves different, in that it is not a 2 pool environment.
>
> Anyhow, if anyone has a pointer as to how to configure things or where
> there may be an article that addresses this specific subject, it'd be
> greatly appreciated. Thanks.
>
> - Mike
>
>
date: Fri, 9 Jun 2006 08:52:56 -0400
author: Robert Ginsburg
Re: ISAPI Extension calling managed code
That sounds like what the sample is doing, except I am not sure if I am reading this right...
"Robert Ginsburg" wrote
> Whenever an unmanaged class needs to retain a pointer to a managed class, you have to
> use GCHandles to hold the pointers.
Again, this does work alright from the mixed .exe (MixedConsole.cpp), in fact with the exe, the debugger set to "Auto" will step through all of the code, which is impressive. Which keeps me leaning towards a compiler setting, or timing.
Anyhow, is this to say that the following implementation might be the issue with the ISAPI extension?
C Unamanged code implementation (MixedIsapi.cpp):
DWORD WINAPI HttpExtensionProc( EXTENSION_CONTROL_BLOCK * pecb )
{
CSimpleClass * clrSimpleClass = new CSimpleClass;
clrSimpleClass->Now();
C Managed Class Declaration (simpleClass.cpp):
#include "simpleClass.h"
#include <gcroot.h>
#using <mscorlib.dll>
using namespace System;
CSimpleClass::CSimpleClass(void){}
CSimpleClass::~CSimpleClass(void) {}
bool CSimpleClass::Now()
{
String^ strServerName = gcnew String("172.31.1.101");
String^ strPath = gcnew String("/test");
return true;
}
Thanks,
- Mike
date: Fri, 9 Jun 2006 10:28:35 -0400
author: mike
Re: ISAPI Extension calling managed code
This is close to what I have done, however I never got it to work by using the gcroot.h include, the compiler always complained. If you drop the gcroot.h include my clr enabled class (which is named remotingproxy) only has the following directives
#using <mscorlib.dll>
#using <System.dll>
#include "StdAfx.h"
#include "RemotingProxy.h"
using namespace System;
using namespace System::Text;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Ipc;
All of the methods of the class expose only unmanaged objects or types that are equivilant (int, bool, etc0. Any instance variables of the class that are actually managed objects are declared in the header as void pointers, and are cast as GCHandle from within the methods when I need to access the managed object. I took this route during the VS 2005 beta, and it continues to work so I saw no reason to rebuild the code. so an untested (sorry did not test it) version of your code with an instance pointer to the string would look lilke this
void* m_ServerName;
#using <mscorlib.dll>
#using <System.dll>
#include "StdAfx.h"
#include "SimpleClass.h"
using namespace System;
using namespace System::Text;
CSimpleClass::CSimpleClass(void){}
CSimpleClass::~CSimpleClass(void) {}
bool CSimpleClass::Now()
{
String^ strServerName = gcnew String("172.31.1.101");
String^ strPath = gcnew String("/test");
GCHandle gcServerName = GCHandle::Alloc( strServerName , GCHandleType::Normal );
System::IntPtr ipServerName = System::Runtime::InteropServices::GCHandle::ToIntPtr(gcServerName );
m_ServerName = ipServerName.ToPointer();
return true;
}
-Robert
"mike" wrote in message news:ex2qdE9iGHA.3780@TK2MSFTNGP03.phx.gbl...
That sounds like what the sample is doing, except I am not sure if I am reading this right...
"Robert Ginsburg" wrote
> Whenever an unmanaged class needs to retain a pointer to a managed class, you have to
> use GCHandles to hold the pointers.
Again, this does work alright from the mixed .exe (MixedConsole.cpp), in fact with the exe, the debugger set to "Auto" will step through all of the code, which is impressive. Which keeps me leaning towards a compiler setting, or timing.
Anyhow, is this to say that the following implementation might be the issue with the ISAPI extension?
C Unamanged code implementation (MixedIsapi.cpp):
DWORD WINAPI HttpExtensionProc( EXTENSION_CONTROL_BLOCK * pecb )
{
CSimpleClass * clrSimpleClass = new CSimpleClass;
clrSimpleClass->Now();
C Managed Class Declaration (simpleClass.cpp):
#include "simpleClass.h"
#include <gcroot.h>
#using <mscorlib.dll>
using namespace System;
CSimpleClass::CSimpleClass(void){}
CSimpleClass::~CSimpleClass(void) {}
bool CSimpleClass::Now()
{
String^ strServerName = gcnew String("172.31.1.101");
String^ strPath = gcnew String("/test");
return true;
}
Thanks,
- Mike
date: Mon, 12 Jun 2006 07:18:14 -0400
author: Robert Ginsburg
|
|