473,396 Members | 1,916 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,396 software developers and data experts.

Again: referencing other generated "InMemory" assembly

Jan
Regarding my post "CSharpCodeProvider: referencing other generated "InMemory"
assembly" 4/27/2006 and the blog from Greg Young
http://geekswithblogs.net/gyoung/arc.../27/76533.aspx

I have now implemented a fine system with code semilar to Greg's example code.

I have a warning/comment/question:

When the generated main assembly is called for the first time (in my
application a static initialize function) another instance of the dependant
assemblies are loaded - and NOT the instances (System.Reflection.Assembly)
you have a reference to from results.CompiledAssembly !!! See trace @ bottom
of post.

That means that any initialization done in the sub-dlls before calling the
main assembly is kind of lost.

And: Files ARE created when named - even if cp.GenerateInMemory is set to
true! They are created in the application directory. That's where they're
loaded from when generated main assembly loads.

I haven't found a method yet to ensure the already loaded dlls are used.

I tried to instanciate an object from each assembly and keep the reference
to make sure that the assemblies does not get unloaded. No difference.

After the compilation the Assembly-reference property "ReflectionOnly" is
false as I expected.

Any help or hints appreciated.
FYI: I have solved the problem for now by letting all generated assemblies
initialize other used assemblies in their static Initialize function. I'm not
pleased with the solution but it works for now. This way I only initialize
yhe actually used instances.
A listing of the problematic scenario from my debug trace:
----------------------------------------------------------------------------

'MyApp.exe' (Managed): Loaded 'Lib1', No symbols loaded.
Initializing runtime sequence file Lib1
..
..
'MyApp.exe' (Managed): Loaded 'Lib2', No symbols loaded.
Initializing runtime sequence file Lib2
..
..
'MyApp.exe' (Managed): Loaded 'Main', No symbols loaded.
'MyApp.exe' (Managed): Loaded 'C:\Test\Lib1.DLL', Symbols loaded.
'MyApp.exe' (Managed): Loaded 'C:\Test\Lib2.DLL', Symbols loaded.
Initializing runtime sequence file Main
May 5 '06 #1
2 1632
I just ran with the example I provided ...

it only loads the assemblies a single time ...

output:

'ConsoleApplication6.vshost.exe' (Managed): Loaded 'C:\Documents and
Settings\Greg Young\My Documents\Visual Studio
2005\Projects\ConsoleApplication6\ConsoleApplicati on6\bin\Debug\ConsoleApplication6.exe',
Symbols loaded.

'ConsoleApplication6.vshost.exe' (Managed): Loaded 'inmemoryassembly', No
symbols loaded.

'ConsoleApplication6.vshost.exe' (Managed): Loaded 'wessmgnq', No symbols
loaded.

'ConsoleApplication6.vshost.exe' (Managed): Loaded 'C:\Documents and
Settings\Greg Young\My Documents\Visual Studio
2005\Projects\ConsoleApplication6\ConsoleApplicati on6\bin\Debug\inmemoryassembly.dll',
No symbols loaded.

"Jan" <j0****************@world.dk> wrote in message
news:63**********************************@microsof t.com...
Regarding my post "CSharpCodeProvider: referencing other generated
"InMemory"
assembly" 4/27/2006 and the blog from Greg Young
http://geekswithblogs.net/gyoung/arc.../27/76533.aspx

I have now implemented a fine system with code semilar to Greg's example
code.

I have a warning/comment/question:

When the generated main assembly is called for the first time (in my
application a static initialize function) another instance of the
dependant
assemblies are loaded - and NOT the instances (System.Reflection.Assembly)
you have a reference to from results.CompiledAssembly !!! See trace @
bottom
of post.

That means that any initialization done in the sub-dlls before calling the
main assembly is kind of lost.

And: Files ARE created when named - even if cp.GenerateInMemory is set to
true! They are created in the application directory. That's where they're
loaded from when generated main assembly loads.

I haven't found a method yet to ensure the already loaded dlls are used.

I tried to instanciate an object from each assembly and keep the reference
to make sure that the assemblies does not get unloaded. No difference.

After the compilation the Assembly-reference property "ReflectionOnly" is
false as I expected.

Any help or hints appreciated.
FYI: I have solved the problem for now by letting all generated assemblies
initialize other used assemblies in their static Initialize function. I'm
not
pleased with the solution but it works for now. This way I only initialize
yhe actually used instances.
A listing of the problematic scenario from my debug trace:
----------------------------------------------------------------------------

'MyApp.exe' (Managed): Loaded 'Lib1', No symbols loaded.
Initializing runtime sequence file Lib1
.
.
'MyApp.exe' (Managed): Loaded 'Lib2', No symbols loaded.
Initializing runtime sequence file Lib2
.
.
'MyApp.exe' (Managed): Loaded 'Main', No symbols loaded.
'MyApp.exe' (Managed): Loaded 'C:\Test\Lib1.DLL', Symbols loaded.
'MyApp.exe' (Managed): Loaded 'C:\Test\Lib2.DLL', Symbols loaded.
Initializing runtime sequence file Main

May 5 '06 #2
n/m it is very late for me now ... I see what you are talking about.

very interesting as it does appear to load it twice.

Cheers,

Greg
"Greg Young" <Dr*************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
I just ran with the example I provided ...

it only loads the assemblies a single time ...

output:

'ConsoleApplication6.vshost.exe' (Managed): Loaded 'C:\Documents and
Settings\Greg Young\My Documents\Visual Studio
2005\Projects\ConsoleApplication6\ConsoleApplicati on6\bin\Debug\ConsoleApplication6.exe',
Symbols loaded.

'ConsoleApplication6.vshost.exe' (Managed): Loaded 'inmemoryassembly', No
symbols loaded.

'ConsoleApplication6.vshost.exe' (Managed): Loaded 'wessmgnq', No symbols
loaded.

'ConsoleApplication6.vshost.exe' (Managed): Loaded 'C:\Documents and
Settings\Greg Young\My Documents\Visual Studio
2005\Projects\ConsoleApplication6\ConsoleApplicati on6\bin\Debug\inmemoryassembly.dll',
No symbols loaded.

"Jan" <j0****************@world.dk> wrote in message
news:63**********************************@microsof t.com...
Regarding my post "CSharpCodeProvider: referencing other generated
"InMemory"
assembly" 4/27/2006 and the blog from Greg Young
http://geekswithblogs.net/gyoung/arc.../27/76533.aspx

I have now implemented a fine system with code semilar to Greg's example
code.

I have a warning/comment/question:

When the generated main assembly is called for the first time (in my
application a static initialize function) another instance of the
dependant
assemblies are loaded - and NOT the instances
(System.Reflection.Assembly)
you have a reference to from results.CompiledAssembly !!! See trace @
bottom
of post.

That means that any initialization done in the sub-dlls before calling
the
main assembly is kind of lost.

And: Files ARE created when named - even if cp.GenerateInMemory is set to
true! They are created in the application directory. That's where they're
loaded from when generated main assembly loads.

I haven't found a method yet to ensure the already loaded dlls are used.

I tried to instanciate an object from each assembly and keep the
reference
to make sure that the assemblies does not get unloaded. No difference.

After the compilation the Assembly-reference property "ReflectionOnly" is
false as I expected.

Any help or hints appreciated.
FYI: I have solved the problem for now by letting all generated
assemblies
initialize other used assemblies in their static Initialize function. I'm
not
pleased with the solution but it works for now. This way I only
initialize
yhe actually used instances.
A listing of the problematic scenario from my debug trace:
----------------------------------------------------------------------------

'MyApp.exe' (Managed): Loaded 'Lib1', No symbols loaded.
Initializing runtime sequence file Lib1
.
.
'MyApp.exe' (Managed): Loaded 'Lib2', No symbols loaded.
Initializing runtime sequence file Lib2
.
.
'MyApp.exe' (Managed): Loaded 'Main', No symbols loaded.
'MyApp.exe' (Managed): Loaded 'C:\Test\Lib1.DLL', Symbols loaded.
'MyApp.exe' (Managed): Loaded 'C:\Test\Lib2.DLL', Symbols loaded.
Initializing runtime sequence file Main


May 5 '06 #3

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

Similar topics

11
by: Jan | last post by:
I'm using the CSharpCodeProvider to buils some assemblies @ runtime which are never saved as files (cp.GenerateInMemory = true;). The generated assemblies are hierachically dependent on each other...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...
0
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...

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.