473,543 Members | 2,715 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loading mixed-mode application without .NET installed

We have an application which uses some mixed-mode code to expose a .NET 1.1
managed API. Only the necessary files are compiled with /clr.

We want to be able to load the application without .NET present, and then
just disable the API.
But we are not even able to give an error message when we start the
application without mscoree.dll present. We have tried delay-loading
mscoree.dll, but that did not help because the OS loader (at least on XP)
forces the initialization of .NET by running _CorExeMain() directly.

Is it possible to disable the .NET initialization?

Regards,
Ståle Hansen
Nov 17 '05 #1
7 1679
"Staale L. Hansen" <st****@winsoft .no> wrote in message
news:e8******** ******@TK2MSFTN GP15.phx.gbl
We have an application which uses some mixed-mode code to expose a
.NET 1.1 managed API. Only the necessary files are compiled with /clr.

We want to be able to load the application without .NET present, and
then just disable the API.
But we are not even able to give an error message when we start the
application without mscoree.dll present. We have tried delay-loading
mscoree.dll, but that did not help because the OS loader (at least on
XP) forces the initialization of .NET by running _CorExeMain()
directly.


Move .NET-dependent code into a separate DLL, delay-load it in your EXE.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Nov 17 '05 #2
The problem is that the API is dependant of a HUGE part of the main
application, and then we also get in trouble with a lot of C++ singleton
objects. This a large native C++ application buildt from almost 100 libs /
dlls. While developing we use DLLs, and everything is OK. But the company is
not willing to ship the application like that, and the release version is
therefore statically linked (including at statically linked mixed-mode
assembly). Making "call-back interfaces" is just not an option, as it is way
too much work.

Kind regards,
Ståle
"Igor Tandetnik" <it********@mvp s.org> wrote in message
news:um******** ******@TK2MSFTN GP14.phx.gbl...
"Staale L. Hansen" <st****@winsoft .no> wrote in message
news:e8******** ******@TK2MSFTN GP15.phx.gbl
We have an application which uses some mixed-mode code to expose a
.NET 1.1 managed API. Only the necessary files are compiled with /clr.

We want to be able to load the application without .NET present, and
then just disable the API.
But we are not even able to give an error message when we start the
application without mscoree.dll present. We have tried delay-loading
mscoree.dll, but that did not help because the OS loader (at least on
XP) forces the initialization of .NET by running _CorExeMain()
directly.


Move .NET-dependent code into a separate DLL, delay-load it in your EXE.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925

Nov 17 '05 #3
In the 2.0 runtime you will only load a very small piece of the .NET runtime
if you do not actually run any managed code, so if you are worrying about
load time or working set issues, they probably already aren't huge in 1.1
and are non existent in 2.0. But you do need the .NET redist installed for
the reasons you state and cannot delayload mscoree.dll. The solution Igor
suggest is the canonical one. I am not sure I understand why you would need
to use "call-back interfaces" just to be able to ship the mixed part as a
separate DLL you can delay load.

You could also create 2 versions of the application and have a shim starter
app determine whether the runtime is available and either load the .NET
enabled version of the app or the non-.Net enabled version of the app.

Ronald Laeremans
Visual C++ team

"Staale L. Hansen" <st****@winsoft .no> wrote in message
news:uG******** ******@tk2msftn gp13.phx.gbl...
The problem is that the API is dependant of a HUGE part of the main
application, and then we also get in trouble with a lot of C++ singleton
objects. This a large native C++ application buildt from almost 100 libs /
dlls. While developing we use DLLs, and everything is OK. But the company
is not willing to ship the application like that, and the release version
is therefore statically linked (including at statically linked mixed-mode
assembly). Making "call-back interfaces" is just not an option, as it is
way too much work.

Kind regards,
Ståle
"Igor Tandetnik" <it********@mvp s.org> wrote in message
news:um******** ******@TK2MSFTN GP14.phx.gbl...
"Staale L. Hansen" <st****@winsoft .no> wrote in message
news:e8******** ******@TK2MSFTN GP15.phx.gbl
We have an application which uses some mixed-mode code to expose a
.NET 1.1 managed API. Only the necessary files are compiled with /clr.

We want to be able to load the application without .NET present, and
then just disable the API.
But we are not even able to give an error message when we start the
application without mscoree.dll present. We have tried delay-loading
mscoree.dll, but that did not help because the OS loader (at least on
XP) forces the initialization of .NET by running _CorExeMain()
directly.


Move .NET-dependent code into a separate DLL, delay-load it in your EXE.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


Nov 17 '05 #4
As the API is a very small part of the application, actually running it
without the .NET framework would be nice (with a disabled API). At least we
need an error message telling what is wrong, but the Windows XP loader just
gives the not too informative message "The application failed to initialize
properly (0xc0000135)". We would also like to get an error message when
running on 1.0, but the application crashes during load when we do that, and
we are not able to show the error message. (We linked with nochkclr.obj, but
did not, and will not use /clr:initialAppD omain.). And if we do not provide
a app.config to say that running on 1.0 is OK, the application just silently
dies with no visible messages (on 1.0 that is).

The API exposes .NET wrapper objects around the core native C++ objects, and
does therefore need to use and access most C++ classes in the core.
Statically linking means that most of the object code are duplicated into
the API dll, and that C++ singleton objects are not single anymore, so
accessing the application objects is not possible.

Kind regards,
Ståle
"Ronald Laeremans [MSFT]" <ro*****@online .microsoft.com> wrote in message
news:e3******** ******@TK2MSFTN GP15.phx.gbl...
In the 2.0 runtime you will only load a very small piece of the .NET
runtime if you do not actually run any managed code, so if you are
worrying about load time or working set issues, they probably already
aren't huge in 1.1 and are non existent in 2.0. But you do need the .NET
redist installed for the reasons you state and cannot delayload
mscoree.dll. The solution Igor suggest is the canonical one. I am not sure
I understand why you would need to use "call-back interfaces" just to be
able to ship the mixed part as a separate DLL you can delay load.

You could also create 2 versions of the application and have a shim
starter app determine whether the runtime is available and either load the
.NET enabled version of the app or the non-.Net enabled version of the
app.

Ronald Laeremans
Visual C++ team

"Staale L. Hansen" <st****@winsoft .no> wrote in message
news:uG******** ******@tk2msftn gp13.phx.gbl...
The problem is that the API is dependant of a HUGE part of the main
application, and then we also get in trouble with a lot of C++ singleton
objects. This a large native C++ application buildt from almost 100 libs
/ dlls. While developing we use DLLs, and everything is OK. But the
company is not willing to ship the application like that, and the release
version is therefore statically linked (including at statically linked
mixed-mode assembly). Making "call-back interfaces" is just not an
option, as it is way too much work.

Kind regards,
Ståle
"Igor Tandetnik" <it********@mvp s.org> wrote in message
news:um******** ******@TK2MSFTN GP14.phx.gbl...
"Staale L. Hansen" <st****@winsoft .no> wrote in message
news:e8******** ******@TK2MSFTN GP15.phx.gbl
We have an application which uses some mixed-mode code to expose a
.NET 1.1 managed API. Only the necessary files are compiled with /clr.

We want to be able to load the application without .NET present, and
then just disable the API.
But we are not even able to give an error message when we start the
application without mscoree.dll present. We have tried delay-loading
mscoree.dll, but that did not help because the OS loader (at least on
XP) forces the initialization of .NET by running _CorExeMain()
directly.

Move .NET-dependent code into a separate DLL, delay-load it in your EXE.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925

Nov 17 '05 #5
Hi Staale,

If you do NOT link with nochkclr.obj then you will get a reasonable error
message if you try to run the image on a 1.0 runtime.

I still don't completely understand why you can't delay load one dll that
contains the managed code or how it relates to having to statically link.

Ronald
"Staale L. Hansen" <st****@winsoft .no> wrote in message
news:u0******** ******@TK2MSFTN GP12.phx.gbl...
As the API is a very small part of the application, actually running it
without the .NET framework would be nice (with a disabled API). At least
we need an error message telling what is wrong, but the Windows XP loader
just gives the not too informative message "The application failed to
initialize properly (0xc0000135)". We would also like to get an error
message when running on 1.0, but the application crashes during load when
we do that, and we are not able to show the error message. (We linked with
nochkclr.obj, but did not, and will not use /clr:initialAppD omain.). And
if we do not provide a app.config to say that running on 1.0 is OK, the
application just silently dies with no visible messages (on 1.0 that is).

The API exposes .NET wrapper objects around the core native C++ objects,
and does therefore need to use and access most C++ classes in the core.
Statically linking means that most of the object code are duplicated into
the API dll, and that C++ singleton objects are not single anymore, so
accessing the application objects is not possible.

Kind regards,
Ståle
"Ronald Laeremans [MSFT]" <ro*****@online .microsoft.com> wrote in message
news:e3******** ******@TK2MSFTN GP15.phx.gbl...
In the 2.0 runtime you will only load a very small piece of the .NET
runtime if you do not actually run any managed code, so if you are
worrying about load time or working set issues, they probably already
aren't huge in 1.1 and are non existent in 2.0. But you do need the .NET
redist installed for the reasons you state and cannot delayload
mscoree.dll. The solution Igor suggest is the canonical one. I am not
sure I understand why you would need to use "call-back interfaces" just
to be able to ship the mixed part as a separate DLL you can delay load.

You could also create 2 versions of the application and have a shim
starter app determine whether the runtime is available and either load
the .NET enabled version of the app or the non-.Net enabled version of
the app.

Ronald Laeremans
Visual C++ team

"Staale L. Hansen" <st****@winsoft .no> wrote in message
news:uG******** ******@tk2msftn gp13.phx.gbl...
The problem is that the API is dependant of a HUGE part of the main
application, and then we also get in trouble with a lot of C++ singleton
objects. This a large native C++ application buildt from almost 100 libs
/ dlls. While developing we use DLLs, and everything is OK. But the
company is not willing to ship the application like that, and the
release version is therefore statically linked (including at statically
linked mixed-mode assembly). Making "call-back interfaces" is just not
an option, as it is way too much work.

Kind regards,
Ståle
"Igor Tandetnik" <it********@mvp s.org> wrote in message
news:um******** ******@TK2MSFTN GP14.phx.gbl...
"Staale L. Hansen" <st****@winsoft .no> wrote in message
news:e8******** ******@TK2MSFTN GP15.phx.gbl
> We have an application which uses some mixed-mode code to expose a
> .NET 1.1 managed API. Only the necessary files are compiled with /clr.
>
> We want to be able to load the application without .NET present, and
> then just disable the API.
> But we are not even able to give an error message when we start the
> application without mscoree.dll present. We have tried delay-loading
> mscoree.dll, but that did not help because the OS loader (at least on
> XP) forces the initialization of .NET by running _CorExeMain()
> directly.

Move .NET-dependent code into a separate DLL, delay-load it in your
EXE.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


Nov 17 '05 #6
Hi Ronald,

Thank you for your answers (and your patience...:)

Yes it is true that we get a reasonable error message, but I do not
understand why we are unable to display our own. Using very simple code that
should be backwards compatible to just display a message should be possible.

The whole solution consists of 99 projects, where one is the application,
one contains the managed code, and the rest contains various classes and
"subsystems ". When we develop (debug config) this generates one application
and 98 DLLs. That is fine and works well (when we were able to handle the
"mixed dll loading problem"). But the company wants us to ship as few DLLs
as possible, one monolithic application being the goal, as it has been
previously. In the Release config everything is linked statically. But
adding the API project caused a lot of unexpected problems.

It is possible to delay load the managed (mixed) DLL, but to be able to make
the DLL it must be linked to the other projects. And since they are no
longer DLLs it must be linked statically, and that is not a working
solution. In the end we actually managed to also statically link the mixed
assembly into the application, and that works great. Except that we are now
totally dependant upon .NET being installed.

Ståle
"Ronald Laeremans [MSFT]" <ro*****@online .microsoft.com> wrote in message
news:OC******** *****@TK2MSFTNG P12.phx.gbl...
Hi Staale,

If you do NOT link with nochkclr.obj then you will get a reasonable error
message if you try to run the image on a 1.0 runtime.

I still don't completely understand why you can't delay load one dll that
contains the managed code or how it relates to having to statically link.

Ronald

Nov 17 '05 #7
Hi Staale,

You can take the checkclr.c source code in the product, modify it according
to you needs, compile it and put the .obj on the link line in front of the
CRT libs to pick up your own custom version. If you just need to output a
different message, you only need to change the _amsg_exit call right at the
end.
It is possible to delay load the managed (mixed) DLL, but to be able to
make the DLL it must be linked to the other projects. And since they are
no longer DLLs it must be linked statically, and that is not a working
solution. In the end we actually managed to also statically link the mixed
assembly into the application, and that works great. Except that we are
now totally dependant upon .NET being installed. I am probably just being dense here, but I still do not understand why you
cannot ship with a monolithic app apart from the 1 mixed mode DLL. Normally
you can decide on a module by module basis whether you statically link or
dynamically link.

Thanks.

Ronald

"Staale L. Hansen" <st****@winsoft .no> wrote in message
news:Oo******** ******@TK2MSFTN GP12.phx.gbl... Hi Ronald,

Thank you for your answers (and your patience...:)

Yes it is true that we get a reasonable error message, but I do not
understand why we are unable to display our own. Using very simple code
that should be backwards compatible to just display a message should be
possible.

The whole solution consists of 99 projects, where one is the application,
one contains the managed code, and the rest contains various classes and
"subsystems ". When we develop (debug config) this generates one
application and 98 DLLs. That is fine and works well (when we were able to
handle the "mixed dll loading problem"). But the company wants us to ship
as few DLLs as possible, one monolithic application being the goal, as it
has been previously. In the Release config everything is linked
statically. But adding the API project caused a lot of unexpected
problems.

It is possible to delay load the managed (mixed) DLL, but to be able to
make the DLL it must be linked to the other projects. And since they are
no longer DLLs it must be linked statically, and that is not a working
solution. In the end we actually managed to also statically link the mixed
assembly into the application, and that works great. Except that we are
now totally dependant upon .NET being installed.

Ståle
"Ronald Laeremans [MSFT]" <ro*****@online .microsoft.com> wrote in message
news:OC******** *****@TK2MSFTNG P12.phx.gbl...
Hi Staale,

If you do NOT link with nochkclr.obj then you will get a reasonable error
message if you try to run the image on a 1.0 runtime.

I still don't completely understand why you can't delay load one dll that
contains the managed code or how it relates to having to statically link.

Ronald


Nov 17 '05 #8

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

Similar topics

3
2558
by: Perttu Pulkkinen | last post by:
No questions, but just consider if this is useful to you:-) but of course feedback & corrections are welcome. function php_mixed_to_js_value($jsname, $mixed) { if(is_null($mixed)) { return "\n $jsname = null;\n"; } elseif(is_string($mixed)) { return "\n $jsname = '$mixed';\n"; } elseif(is_numeric($mixed) || is_boolean($mixed))
6
5569
by: Xerxes | last post by:
Hi, at startup I get three similar error messages about three DLLs: php_sqlite.dll, php_curl.dll and php_gd2.dll. I searched the group for similar problem but the solutions proposed there did not help. - I copied the DLLs to Windows directory - I checked php.ini to make sure the extensions were uncommented and there was an extension_dir...
2
1751
by: Paul A. Hoadley | last post by:
Hello, I am trying to convert a RELAX NG schema to DTD using Trang. I am currently trying to add some inline elements to the schema, such as <emph> for marking emphasised text. Here is an excerpt from the schema: <define name="description"> <element name="description"> <mixed>
4
1714
by: Daniel Mori | last post by:
Im at a loss on where to proceed next. I wonder if anyone can help me. I have a managed C++ DLL is basically a thin wrapper around several unmanaged classes. This DLL builds fine. In my main C# application I have setup a project reference to this DLL. Im able to reference these managed .DLL classes from within my code without problem.
15
5383
by: Bill Cohagan | last post by:
I'm trying to generate class definitions from an XSD that contains something like: <xs:complexType name="foo" mixed="true"> <xs:choice minOccurs = "0" maxOccurs="unbounded"> <xs:element name = "bar" type = "something"/> ... <xs:element name = "baz" type = "somethingelse"/> </xs:choice> </xs:complexType>
2
1587
by: bearophileHUGS | last post by:
Notes: - This email is about Mark Dufour's Shed Skin (SS) (http://shed-skin.blogspot.com), but the errors/ingenuousness it contains are mine. My experience with C++ is limited still. - The following code comes from a discussion with Mark. One of the purposes of SS is to produce fast-running programs (compiling a subset of Python code to...
3
2759
by: Mali Guven | last post by:
Hello, I have a native DLL (written in C) which is supposed to call a managed DLL (was written in C#, and an entry point was injected modifying the ildasm'd code). The exectuable calls the native DLL but the native DLL fails to load the managed DLL. The paper that addresses the 'mixed DLL problem' below does not offer any understandable...
7
4789
by: =?Utf-8?B?SmltIFdhbHNo?= | last post by:
I'm new to working with mixed assemblies. All of my previous experience has been with VC++/MFC in native, unmanaged applications. When I create a mixed assembly in which one or more of the files compiles with /clr the instructions say that I need to change the switch for Debug information format from Program Database for Edit & Continue to...
2
3792
by: =?Utf-8?B?SmVmZnJleQ==?= | last post by:
How to configure the IIS, ASPNET userID, Windows or SQL Authentiation, std or integrated security for SQLserver database? The VS.net 2002 web server and SQL Server client are at the same PC, while the SQL Server database is at another PC. The dataset and DataGrid were created successfully. However, when trying to run a Web Form with a...
1
1920
by: bizt | last post by:
Hi, I have a webpage where Im creating AJAX type requests by loading dynamic pages containg JavaScript into hidden iFrames. The reason I am opting for this method over XmlHttpRequest object requests is because I wish for some of my requests to be over a secure https:// connection and other not so private requests to be made over http:// .....
0
7397
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7336
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7726
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7329
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7675
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5257
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3385
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1809
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
626
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.