472,958 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

assembly loading problem

Hi

I'm currently working on a forms designer for a free .NET IDE
(SharpDevelop -> www.icsharpcode.net/OpenSource/SD).

problem:
I try to put 'custom' components (user controls from the current open
project) into the forms designer. The project must be compiled for
making this work. Now after recompile I need to update the user control
with the newly compiled version (maybe something has changed). And THAT
is the problem. I can't unload assemblies from the main app domain and I
assume that I can't use another appdomain for the forms designer
(because controls can't be exchanged between domain boundaries ... and I
need to show it somewhere). Therefore all I need is a solution to the
'update' problem.

Regards
Mike

Nov 13 '05 #1
3 4657
You'll need to have both your designer and your control in a separate
domain. Then when-ever you need to refresh the control, you'll need to tear
down that domain and create a new one.

--
--Grant
This posting is provided "AS IS" with no warranties, and confers no rights.
"Mike Krueger" <mi**@icsharpcode.net> wrote in message
news:Og**************@TK2MSFTNGP12.phx.gbl...
Hi

I'm currently working on a forms designer for a free .NET IDE
(SharpDevelop -> www.icsharpcode.net/OpenSource/SD).

problem:
I try to put 'custom' components (user controls from the current open
project) into the forms designer. The project must be compiled for
making this work. Now after recompile I need to update the user control
with the newly compiled version (maybe something has changed). And THAT
is the problem. I can't unload assemblies from the main app domain and I
assume that I can't use another appdomain for the forms designer
(because controls can't be exchanged between domain boundaries ... and I
need to show it somewhere). Therefore all I need is a solution to the
'update' problem.

Regards
Mike

Nov 13 '05 #2
Hi

Then I've two problems:

1. I can't share types between appdomains without having their
assemblies loaded in the appdomain as well.

2. I can't share windows.forms user controls over appdomain boundaries
(therefore I need at least the windows.forms designer in the main
appdomain ... because of problem 1 I couldn't test what happens if I try
to put a 'remote' control into the forms designer ... but I suppose that
this fails like remoting any other windows forms control :/)

My current solution for the problem is as follows:

Overwriting the AssemblyResolve event in the appdomain and >hard core<
loading the assemblies from the disc using a byte[] array (with this
trick I get around the locking problem).

But with this dirty hack I've another problem: a memory leak :/ but
currently I can't see an solution for getting around this problem. I've
dissassembled the TypeDesigner from Microsoft.VisualStudio.dll (which is
delivered with the framework, not with the IDE). And there its a
toolbox manager which does almost the same as I do as far as I can tell
except they don't load the assembly with the byte hack instead they're
copying it to a temporary location (Somewhere in the users appdata
folder) and there they load it with Assembly.LoadFile (LoadFile does
load assemblies twice, if needed LoadFrom doesn't do this it first looks
into the current appdomain).
Am I right that VS.NET has a memory leak ? And it allocates a few bytes
every time an assembly with an user control is recompiled ?

but nevertheless the AppDomain load/unload workaround would be nice if
it would work but I can't see to prevent the automatic assembly load, if
I transfer types and the unability to share controls between
appdomains in the same process is really a hard problem for C# users.
But maybe I'm completly wrong or I haven't seen another solution ?

Regards
Mike
You'll need to have both your designer and your control in a separate
domain. Then when-ever you need to refresh the control, you'll need to tear
down that domain and create a new one.


Nov 13 '05 #3
I don't know what the VS.NET designer does. You are correct as far as #1.
That's why you have to create a really good interface/class that will NOT
change, and can safely be loaded into both app domains, and can do the
appropriate communication between domains. The way I envision this
happening is that the shell and UI are all in your 'primary domain'. You
then start a secondary domain for the toolbox and designer. All code that
deals directly with control types has to go in the secondary domain. Then
whenever a control needs to be refreshed, you restart the secondary domain.

--
--Grant
This posting is provided "AS IS" with no warranties, and confers no rights.
"Mike Krueger" <mi**@icsharpcode.net> wrote in message
news:3F**************@icsharpcode.net...
Hi

Then I've two problems:

1. I can't share types between appdomains without having their
assemblies loaded in the appdomain as well.

Nov 13 '05 #4

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

Similar topics

0
by: Brent | last post by:
I maintain a Sql Server database application whose forms are compiled in a .dll and kept in a remote web folder. The main .exe looks to the web folder to see if this .dll exists. If so, then it...
4
by: Arnaud Debaene | last post by:
Hello group. I have an app which can load "plugins" assemblies that are described in the registry (each registry entry gives the full path to the plugin ..dll file). The plugins may be anywhere...
3
by: Atul Godbole | last post by:
Suppose an assembly "Main" is using class "A" from another Assembly "Dep" as follows : A a = new A(); a.MethodOne(); At what time is the call to MethodOne linked to the actual MSIL (method...
4
by: Mark | last post by:
I wan't to be able to deserialize a class from an assembly that is not in the application domain. To do that I must have the Type from the Assembly. How do you get a Type from an assembly that is...
1
by: Benjamin | last post by:
Hi, I'm currently writing a Web Services that interacts with a database. To allow me to use not just one database provider (for example, I could use MS Access, SQL Server or MySQL), the Web...
1
by: Brian | last post by:
I've looked through the previous posts on this one and have verified permissions and location of my Dlls, but I am still getting an exception when I try to Load an assembly. The directory where...
2
by: peter.drienovsky | last post by:
Hello, let me describe my problem: ENVIRONMENT: ..Net 2.0, MSVS 2005, c#, WinXP SYMPTOMS: If assembly 'AgentDesktop' IS NOT in the (loading) application folder,
2
by: Chen Zhuo | last post by:
Hi all experts, We are having a problem with the exact time when a C# dll gets loaded in managed C++. The scenario is like: In managed.cpp: #using MyCSharp.dll
2
by: millevlada | last post by:
Hi all. Here is description of my run-time assembly loading problem: I would like to have winService hosting .Net remoting objects. But, it should work in sort of pluginable way, so during...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.