473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

globals in unmanaged space

Hello All,

we are doing a quite a big project that contains at
the lowest level an unmenaged c++ classes. Above it there
are managed wrappers and at the top there are ASP.NET
pages. Can anyone tell me how to force ASP.NET not
to "clear" or reinitialize unmenaged global or static
variables that are set on unmanaged level between
successive requests?

To be more clear: currenly every global variable from
unmanaged heap that gets changed from within any umnamaged
method gets reinitialized on the next request. I'm
particularly interested in keeping intact some global
pointers - currently they get NULL on successive
requests thoungh destructors of objects that they pointed
before request are not called i.e. the objects somehow are
lost.

Any advice is appreciated.
Greetings
Marek

Nov 18 '05 #1
6 1279
..NET does not affect unmanaged variables.
How can it? it has no information about them?

Most likely it's a problem in C++ classes. How do you call your C++
classes?

Are they COM objects or wrapped into DLL calls?

George.

"marek" <ma***@wp.pl> wrote in message
news:0d****************************@phx.gbl...
Hello All,

we are doing a quite a big project that contains at
the lowest level an unmenaged c++ classes. Above it there
are managed wrappers and at the top there are ASP.NET
pages. Can anyone tell me how to force ASP.NET not
to "clear" or reinitialize unmenaged global or static
variables that are set on unmanaged level between
successive requests?

To be more clear: currenly every global variable from
unmanaged heap that gets changed from within any umnamaged
method gets reinitialized on the next request. I'm
particularly interested in keeping intact some global
pointers - currently they get NULL on successive
requests thoungh destructors of objects that they pointed
before request are not called i.e. the objects somehow are
lost.

Any advice is appreciated.
Greetings
Marek

Nov 18 '05 #2
Hi,

thanks for reply.

We have a full control on unmanaged code. Basically all
managed classes that are used on aspx pages look like that
presented below

#include "Unmanaged/User.h"

namespace ManagedWrappers
{
__gc public class CUserWrp
{
public:
CUserWrp(String login, String password);
virtual ~CUserWrp();
CUserWrp* GetUser();

private:
CUser* m_pUserCtr; // unmanaged member
};
}

We have some globals in a cpp file where unmanaged CUser
is defined. This file together with the other unamanaged
stuff is compiled to Unmanaged.lib and then linked to
ManagedWrappers.dll and finally with *.cs files to
TheWholeProject.dll.

Globals are initialized on a call from a page i.e. a full
file path of the default.aspx page is retrieved on
global.asax and passed to unmanaged space by some
unmanaged method. Then the other function from the page
(but still on that first request) is able to call another
unamanged method that uses aproprietly set globals within
unmanaged space.

Than when the next request comes in all the globals are
reset - pointers are set to NULL. I thought that when it's
basically the same thread space (TheWholeProject.dll) the
unmanaged space will not be reset. By default it seems to
be. But I believe it is possible somehow to have it
unchanged on the next request - or I'm wrong and have to
reprogram quite a bit of code.

Any advice appreciated
Greetings
Marek
-----Original Message-----
..NET does not affect unmanaged variables.
How can it? it has no information about them?

Most likely it's a problem in C++ classes. How do you call your C++classes?

Are they COM objects or wrapped into DLL calls?

George.

"marek" <ma***@wp.pl> wrote in message
news:0d****************************@phx.gbl...
Hello All,

we are doing a quite a big project that contains at
the lowest level an unmenaged c++ classes. Above it there are managed wrappers and at the top there are ASP.NET
pages. Can anyone tell me how to force ASP.NET not
to "clear" or reinitialize unmenaged global or static
variables that are set on unmanaged level between
successive requests?

To be more clear: currenly every global variable from
unmanaged heap that gets changed from within any umnamaged method gets reinitialized on the next request. I'm
particularly interested in keeping intact some global
pointers - currently they get NULL on successive
requests thoungh destructors of objects that they pointed before request are not called i.e. the objects somehow are lost.

Any advice is appreciated.
Greetings
Marek

.

Nov 18 '05 #3
The only thing i can think of is following.

The DLL which is using managed and unmanaged classes is called mixed mode
DLL

Usually with unmanaged DLL C++ runtime must be initialized first.
Also C++ runtime initializes global variables.
In regular DLL/EXE compiler sets entry point to initlization routine and
then execution goes to DllMain/WinMain
When .NET calls mixed mode DLL it ignores the entry point set by compiler
and using it's own (.NET ) entry point.

So you must initialize C++ runtime manually.

So my guess you do it (initialize C++ runtime) on each browser request as
opppose to do it only once.

George.

"marek" <ma***@wp.pl> wrote in message
news:01****************************@phx.gbl...
Hi,

thanks for reply.

We have a full control on unmanaged code. Basically all
managed classes that are used on aspx pages look like that
presented below

#include "Unmanaged/User.h"

namespace ManagedWrappers
{
__gc public class CUserWrp
{
public:
CUserWrp(String login, String password);
virtual ~CUserWrp();
CUserWrp* GetUser();

private:
CUser* m_pUserCtr; // unmanaged member
};
}

We have some globals in a cpp file where unmanaged CUser
is defined. This file together with the other unamanaged
stuff is compiled to Unmanaged.lib and then linked to
ManagedWrappers.dll and finally with *.cs files to
TheWholeProject.dll.

Globals are initialized on a call from a page i.e. a full
file path of the default.aspx page is retrieved on
global.asax and passed to unmanaged space by some
unmanaged method. Then the other function from the page
(but still on that first request) is able to call another
unamanged method that uses aproprietly set globals within
unmanaged space.

Than when the next request comes in all the globals are
reset - pointers are set to NULL. I thought that when it's
basically the same thread space (TheWholeProject.dll) the
unmanaged space will not be reset. By default it seems to
be. But I believe it is possible somehow to have it
unchanged on the next request - or I'm wrong and have to
reprogram quite a bit of code.

Any advice appreciated
Greetings
Marek
-----Original Message-----
..NET does not affect unmanaged variables.
How can it? it has no information about them?

Most likely it's a problem in C++ classes. How do you

call your C++
classes?

Are they COM objects or wrapped into DLL calls?

George.

"marek" <ma***@wp.pl> wrote in message
news:0d****************************@phx.gbl...
Hello All,

we are doing a quite a big project that contains at
the lowest level an unmenaged c++ classes. Above it there are managed wrappers and at the top there are ASP.NET
pages. Can anyone tell me how to force ASP.NET not
to "clear" or reinitialize unmenaged global or static
variables that are set on unmanaged level between
successive requests?

To be more clear: currenly every global variable from
unmanaged heap that gets changed from within any umnamaged method gets reinitialized on the next request. I'm
particularly interested in keeping intact some global
pointers - currently they get NULL on successive
requests thoungh destructors of objects that they pointed before request are not called i.e. the objects somehow are lost.

Any advice is appreciated.
Greetings
Marek

.

Nov 18 '05 #4
Yeah I think your advice will solve the problem helpful.
I'll check it tomorrow.

BTW - where can I read about this entry point stuff as you
wrote? Is it really true? If they just ignore an entry
point for mixed dlls it's just a horrible hole. Maybe it's
possible to force .net somehow not to ignore it just like
that ...
Thanks anyway.
waiting for further comments
Greetings
Marek
-----Original Message-----
The only thing i can think of is following.

The DLL which is using managed and unmanaged classes is called mixed modeDLL

Usually with unmanaged DLL C++ runtime must be initialized first.Also C++ runtime initializes global variables.
In regular DLL/EXE compiler sets entry point to initlization routine andthen execution goes to DllMain/WinMain
When .NET calls mixed mode DLL it ignores the entry point set by compilerand using it's own (.NET ) entry point.

So you must initialize C++ runtime manually.

So my guess you do it (initialize C++ runtime) on each browser request asopppose to do it only once.

George.

"marek" <ma***@wp.pl> wrote in message
news:01****************************@phx.gbl...
Hi,

thanks for reply.

We have a full control on unmanaged code. Basically all
managed classes that are used on aspx pages look like that presented below

#include "Unmanaged/User.h"

namespace ManagedWrappers
{
__gc public class CUserWrp
{
public:
CUserWrp(String login, String password);
virtual ~CUserWrp();
CUserWrp* GetUser();

private:
CUser* m_pUserCtr; // unmanaged member
};
}

We have some globals in a cpp file where unmanaged CUser
is defined. This file together with the other unamanaged
stuff is compiled to Unmanaged.lib and then linked to
ManagedWrappers.dll and finally with *.cs files to
TheWholeProject.dll.

Globals are initialized on a call from a page i.e. a full file path of the default.aspx page is retrieved on
global.asax and passed to unmanaged space by some
unmanaged method. Then the other function from the page
(but still on that first request) is able to call another unamanged method that uses aproprietly set globals within unmanaged space.

Than when the next request comes in all the globals are
reset - pointers are set to NULL. I thought that when it's basically the same thread space (TheWholeProject.dll) the unmanaged space will not be reset. By default it seems to be. But I believe it is possible somehow to have it
unchanged on the next request - or I'm wrong and have to
reprogram quite a bit of code.

Any advice appreciated
Greetings
Marek
>-----Original Message-----
>..NET does not affect unmanaged variables.
>How can it? it has no information about them?
>
>Most likely it's a problem in C++ classes. How do you

call your C++
>classes?
>
>Are they COM objects or wrapped into DLL calls?
>
>George.
>
>"marek" <ma***@wp.pl> wrote in message
>news:0d****************************@phx.gbl...
>> Hello All,
>>
>> we are doing a quite a big project that contains at >> the lowest level an unmenaged c++ classes. Above it

there
>> are managed wrappers and at the top there are ASP.NET
>> pages. Can anyone tell me how to force ASP.NET not
>> to "clear" or reinitialize unmenaged global or static
>> variables that are set on unmanaged level between
>> successive requests?
>>
>> To be more clear: currenly every global variable from >> unmanaged heap that gets changed from within any

umnamaged
>> method gets reinitialized on the next request. I'm
>> particularly interested in keeping intact some global
>> pointers - currently they get NULL on successive
>> requests thoungh destructors of objects that they

pointed
>> before request are not called i.e. the objects
somehow are
>> lost.
>>
>> Any advice is appreciated.
>> Greetings
>> Marek
>>
>
>
>.
>

.

Nov 18 '05 #5
May be this article will help.

http://msdn.microsoft.com/library/de...omixedmode.asp
George.

"marek" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
Yeah I think your advice will solve the problem helpful.
I'll check it tomorrow.

BTW - where can I read about this entry point stuff as you
wrote? Is it really true? If they just ignore an entry
point for mixed dlls it's just a horrible hole. Maybe it's
possible to force .net somehow not to ignore it just like
that ...
Thanks anyway.
waiting for further comments
Greetings
Marek
-----Original Message-----
The only thing i can think of is following.

The DLL which is using managed and unmanaged classes is

called mixed mode
DLL

Usually with unmanaged DLL C++ runtime must be

initialized first.
Also C++ runtime initializes global variables.
In regular DLL/EXE compiler sets entry point to

initlization routine and
then execution goes to DllMain/WinMain
When .NET calls mixed mode DLL it ignores the entry point

set by compiler
and using it's own (.NET ) entry point.

So you must initialize C++ runtime manually.

So my guess you do it (initialize C++ runtime) on each

browser request as
opppose to do it only once.

George.

"marek" <ma***@wp.pl> wrote in message
news:01****************************@phx.gbl...
Hi,

thanks for reply.

We have a full control on unmanaged code. Basically all
managed classes that are used on aspx pages look like that presented below

#include "Unmanaged/User.h"

namespace ManagedWrappers
{
__gc public class CUserWrp
{
public:
CUserWrp(String login, String password);
virtual ~CUserWrp();
CUserWrp* GetUser();

private:
CUser* m_pUserCtr; // unmanaged member
};
}

We have some globals in a cpp file where unmanaged CUser
is defined. This file together with the other unamanaged
stuff is compiled to Unmanaged.lib and then linked to
ManagedWrappers.dll and finally with *.cs files to
TheWholeProject.dll.

Globals are initialized on a call from a page i.e. a full file path of the default.aspx page is retrieved on
global.asax and passed to unmanaged space by some
unmanaged method. Then the other function from the page
(but still on that first request) is able to call another unamanged method that uses aproprietly set globals within unmanaged space.

Than when the next request comes in all the globals are
reset - pointers are set to NULL. I thought that when it's basically the same thread space (TheWholeProject.dll) the unmanaged space will not be reset. By default it seems to be. But I believe it is possible somehow to have it
unchanged on the next request - or I'm wrong and have to
reprogram quite a bit of code.

Any advice appreciated
Greetings
Marek

>-----Original Message-----
>..NET does not affect unmanaged variables.
>How can it? it has no information about them?
>
>Most likely it's a problem in C++ classes. How do you
call your C++
>classes?
>
>Are they COM objects or wrapped into DLL calls?
>
>George.
>
>"marek" <ma***@wp.pl> wrote in message
>news:0d****************************@phx.gbl...
>> Hello All,
>>
>> we are doing a quite a big project that contains at >> the lowest level an unmenaged c++ classes. Above it
there
>> are managed wrappers and at the top there are ASP.NET
>> pages. Can anyone tell me how to force ASP.NET not
>> to "clear" or reinitialize unmenaged global or static
>> variables that are set on unmanaged level between
>> successive requests?
>>
>> To be more clear: currenly every global variable from >> unmanaged heap that gets changed from within any
umnamaged
>> method gets reinitialized on the next request. I'm
>> particularly interested in keeping intact some global
>> pointers - currently they get NULL on successive
>> requests thoungh destructors of objects that they
pointed
>> before request are not called i.e. the objects somehow are
>> lost.
>>
>> Any advice is appreciated.
>> Greetings
>> Marek
>>
>
>
>.
>

.

Nov 18 '05 #6
Thanks ...

and in addition I was advised this one

http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/dv_vstechart/html/vcconMixedDLLLoadingProblem.asp
merry christmas to all
Marek
-----Original Message-----
May be this article will help.

http://msdn.microsoft.com/library/default.asp? url=/library/en-
us/vcmex/html/vcconconvertingmanagedextensionsforcprojectsf
rompureintermediatelanguagetomixedmode.asp

George.

"marek" <an*******@discussions.microsoft.com> wrote in messagenews:04****************************@phx.gbl...
Yeah I think your advice will solve the problem helpful.
I'll check it tomorrow.

BTW - where can I read about this entry point stuff as you wrote? Is it really true? If they just ignore an entry
point for mixed dlls it's just a horrible hole. Maybe it's possible to force .net somehow not to ignore it just like that ...
Thanks anyway.
waiting for further comments
Greetings
Marek
>-----Original Message-----
>The only thing i can think of is following.
>
>The DLL which is using managed and unmanaged classes is

called mixed mode
>DLL
>
>Usually with unmanaged DLL C++ runtime must be

initialized first.
>Also C++ runtime initializes global variables.
>In regular DLL/EXE compiler sets entry point to

initlization routine and
>then execution goes to DllMain/WinMain
>
>
>When .NET calls mixed mode DLL it ignores the entry point
set by compiler
>and using it's own (.NET ) entry point.
>
>So you must initialize C++ runtime manually.
>
>So my guess you do it (initialize C++ runtime) on each

browser request as
>opppose to do it only once.
>
>George.
>
>
>
>"marek" <ma***@wp.pl> wrote in message
>news:01****************************@phx.gbl...
>> Hi,
>>
>> thanks for reply.
>>
>> We have a full control on unmanaged code. Basically
all >> managed classes that are used on aspx pages look like

that
>> presented below
>>
>> #include "Unmanaged/User.h"
>>
>> namespace ManagedWrappers
>> {
>> __gc public class CUserWrp
>> {
>> public:
>> CUserWrp(String login, String password);
>> virtual ~CUserWrp();
>> CUserWrp* GetUser();
>>
>> private:
>> CUser* m_pUserCtr; // unmanaged member
>> };
>> }
>>
>> We have some globals in a cpp file where unmanaged CUser >> is defined. This file together with the other unamanaged >> stuff is compiled to Unmanaged.lib and then linked to
>> ManagedWrappers.dll and finally with *.cs files to
>> TheWholeProject.dll.
>>
>> Globals are initialized on a call from a page i.e. a

full
>> file path of the default.aspx page is retrieved on
>> global.asax and passed to unmanaged space by some
>> unmanaged method. Then the other function from the page >> (but still on that first request) is able to call

another
>> unamanged method that uses aproprietly set globals

within
>> unmanaged space.
>>
>> Than when the next request comes in all the globals are >> reset - pointers are set to NULL. I thought that when

it's
>> basically the same thread space (TheWholeProject.dll)

the
>> unmanaged space will not be reset. By default it seems to
>> be. But I believe it is possible somehow to have it
>> unchanged on the next request - or I'm wrong and

have to >> reprogram quite a bit of code.
>>
>> Any advice appreciated
>> Greetings
>> Marek
>>
>> >-----Original Message-----
>> >..NET does not affect unmanaged variables.
>> >How can it? it has no information about them?
>> >
>> >Most likely it's a problem in C++ classes. How do you >> call your C++
>> >classes?
>> >
>> >Are they COM objects or wrapped into DLL calls?
>> >
>> >George.
>> >
>> >"marek" <ma***@wp.pl> wrote in message
>> >news:0d****************************@phx.gbl...
>> >> Hello All,
>> >>
>> >> we are doing a quite a big project that

contains at
>> >> the lowest level an unmenaged c++ classes. Above it >> there
>> >> are managed wrappers and at the top there are ASP.NET >> >> pages. Can anyone tell me how to force ASP.NET not
>> >> to "clear" or reinitialize unmenaged global or static >> >> variables that are set on unmanaged level between
>> >> successive requests?
>> >>
>> >> To be more clear: currenly every global variable

from
>> >> unmanaged heap that gets changed from within any
>> umnamaged
>> >> method gets reinitialized on the next request. I'm
>> >> particularly interested in keeping intact some global >> >> pointers - currently they get NULL on successive
>> >> requests thoungh destructors of objects that they
>> pointed
>> >> before request are not called i.e. the objects

somehow
>> are
>> >> lost.
>> >>
>> >> Any advice is appreciated.
>> >> Greetings
>> >> Marek
>> >>
>> >
>> >
>> >.
>> >
>
>
>.
>

.

Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Brian Kendig | last post by:
The server I'm running my PHP on has "magic_quotes" turned on, so all the input I get (from GET, POST, and cookies) is escaped with backslashes. I don't want this (I handle my own escaping, and I...
11
by: Matt | last post by:
Hello, I'm rather new to C++ and have a question about globals. What is the big deal about them? They make things much easier to program because you don't have to worry about all the passing...
2
by: Marek Malowidzki | last post by:
Hi all, I am writing a component that exposes a C++ library as a .NET component. The approach is somewhat automatic: every library C++ class has its managed C++ counterpart that keeps a pointer...
3
by: Mark Urish | last post by:
Is there a way to import data from an unmanaged dll? For example, unmanaged.dll: __declspec(dllexport) int unmanagedErrno; managed.cs: class Managed { //this doesn't work:
7
by: Chris | last post by:
Background: We have developed an C# MDI (Multi-Document Interface) application which loads different assemblies/forms, so that the user can have many "application windows" running within the...
7
by: Klaus Bonadt | last post by:
I have an existing VC6 application using the MFC. I am able to pass CString and other parameters from such a VC6 dll to an unmanaged MFC dll (compiled in Visual Studio .NET). Now I want to use...
18
by: robert | last post by:
Using global variables in Python often raises chaos. Other languages use a clear prefix for globals. * you forget to declare a global * or you declare a global too much or in conflict * you...
20
by: =?Utf-8?B?VGhlTWFkSGF0dGVy?= | last post by:
Sorry to bring up a topic that is just flogging a dead horse.... but... On the topic of memory management.... I am doing some file parcing that has to be done as quick as posible, but what I...
7
by: CapnBearbossa | last post by:
hi all, forgive me , but the RTFM and Google search approaches are not yielding an answer on this question. I need to know if there's a top level python interpreter command that clears all user...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.