|
I didn't say that you can unload an assembly, I said that you can "unload" your plugin (by nullifying or disposing the instance of the plugin class). This is the common approach. See my sig - trust me, I know.
In order to work with the UI, messages must be sent to the control in the same thread that the control was created in. Since AppDomain are separate from each other, these threads are not accessible from another AppDomain . As I said before, process the input from the plugins and fire an event that can be remoted across application boundaries that your main application can handle. It's a lot of extra work for something so trivial, though. Honestly, does your app have so many plugins (which could all be in one assembly anyway, if needs be) that you must unload the assembly in which the plugin is contained?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
first, i must say thanks a lot for the help, really appreciate it.
but the .dll file will still take up memory unless you unload the domain, doesn't it?
but i don't really understand what you mean about the UI.
everything in the form (created from the plugin in the separate AppDomain) work like a charm, EXCEPT ProcessDialogKey. you say "process the input from the plugins and fire an event that can be remoted across application boundaries that your main application can handle", but it is the plugins that want the event. the plugin have created the form, but the ProcessDialogKey is just not called when i press the TAB key etc.
really sorry if i misunderstood you.
|
|
|
|
|
zilch wrote:
but the .dll file will still take up memory unless you unload the domain, doesn't it?
Yes, but not very much depending on the size of the assembly (and how much IL has been JIT'd). On modern machines, this is very moot unless you plan on having 100s of plugins or something. Our flagship enterprise app uses dozens of rich plugins and - while everything is disposed properly - doesn't use much memory (as far as managed applications go). The majority of memory is used for instances of your classes, not the assembly or the JIT'd native instructions that are cached. If you ship several plugins for your application, consider grouping these classes together. The .NET Framework Class Library (FCL) doesn't have one class per assembly, does it? Having to unload the assemblies once the plugins that contain it is not necessary except in rare cases when memory is a problem (like on Windows CE platforms).
So you're saying the plugins are not getting ProcessDialogKey called in the forms that the plugins create? Are these modal or modeless dialogs? Are these dialogs created in separate threads? The forms are actually classes in the plugin assembly (loaded into a different AppDomain )? I'm just trying to understand what exactly is doing what.
Seriously, though, consider dropping separate AppDomain s. Communicating within the same AppDomain is so much easier if you need your plugins to talk to either other or to the main application. The assemblies for plugins aren't loaded until the Type that needs to be loaded and executed (from that assembly) is needed anyway. Depending on how your application loads plugins (like ours works like the COM registry to enumerate plugins from the .config file but doesn't create them until they're needed), many of them might not get loaded anyway.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i get your point with the memory, i'll think more about it.
but the real issue here is the ProcessDialogKey. Yes the plugins create the forms themselves. From the contextmenu on the NotifyIcon i press the name of the plugin. The hidden GUI responds to this and calls Execute() on the plugin in the other AppDomain. From here they create their own forms. They are modeless (Show). I tried making them modal now (ShowDialog) and strangely ProcessDialogKey did get called! However (!) this messes things up as other plugin forms already showing can't get focus if i don't close the modal one first (i only tried making one plugin modal, and i need many plugins showing at the same time). I don't create any threads anywhere (except before the call to Application.Run()).
I am considering dropping them now, but only then becuase of ProcessDialogKey. I have already made the whole infrastructure adapted for remoting. And yes you are right, its much easier with one AppDomain.
thanks again, very kind of you to help me.
|
|
|
|
|
i changed form.Show() in the plugin to Application.Run( form ) and now it works. That, I call magic. why does it work now? i don't see the connection, but then again win32 message loops are not my strong side
|
|
|
|
|
Did you ever resolve this? We have a plugin system that really needs to be in a separate AppDomain, but when we place the plugin (which is a form) in its own AppDomain, ProcessDialogKey is never being called.
Thanks!
-Greg
|
|
|
|
|
hi
i want to hide the task bar from my app ??
and i want to maximze certain weindow i have its handle
if anyone knows plz tell me thanx
|
|
|
|
|
Use the SendMessage Win32 API to maximize another window. I'm not sure what you mean by hide the taskbar from the app ... if you mean don't show your app in the taskbar, you can use myForm.ShowInTaskbar = false; . If you mean make the taskbar invisible, you'll probably have to P/Invoke the Win32 API once again.
---------------------------
He who knows that enough is enough will always have enough.
-Lao Tsu
|
|
|
|
|
I think the following fits much better than SendMessage. The code shows declaration and usage.
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern bool ShowWindow(int wndHandle, int nCmdShow);
ShowWindow(wndHandle, 3);
To set other window states than maximized read the help of the ShowWindow method in the Platform-SDK. The define-values which are mentioned there, can be found in Winuser.h.
|
|
|
|
|
Another way is to set Form.Bounds to SystemInformation . Also set Form.FormBorderStyle to FormBorderStyle.None . This will draw your window over top of the task bar. Note that this requires no P/Invoked calls directly, while the underlying effect is the same as other full-screen applications (including screen savers) that you see, since pretty much all the controls (including the Form class) encapsulates native APIs for Windows Management and Common Controls.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I have a dataset object and I am filling it with the rows of a table.Now I assigned it to a datagrid object.I don't know the schema of the table.Now I want the schema of the table and the data type of each attribute in the schema.How do I get this?
Karteek
|
|
|
|
|
You can't get the schema from the DataGrid like you're probably hoping. You could construct an XmlDocument (or use an XmlTextWriter ) to build a schema while enumerating through the tables and column definitions, but the easiest way is to create a typed DataSet by adding a new DataSet schema to your project and designing the desired schema in there. VS.NET can generate a typed DataSet class (with actual table and column names, as well as the proper column types and fewer look-ups). You can use this to bind more easily to a DataGrid . At the very least - if you don't want to use the actual typed DataSet - you'll have a schema that you can use for DataSet.ReadXmlSchema for a generic DataSet instance.
To bind to a DataGrid , though, you really don't need to know the schema in advance. You can always set the DataGrid.DataSource property to the DataSet instance (filled) and optionally set the DataMember to myDataSet.Tables[0].TableName . By default, columns are generated automatically. If you know the schema up-front - you don't even have to import any schema - you can pre-set the DataGrid.DataMember property to the table name and add a DataGridTableStyle to DataGrid.TableStyles that uses the same table name. Optionally, you can add various DataGridColumnStyle sd to the associated DataGridTableStyle.GridColumnStyles collection property and set DataGrid.AutoGenerateColumns to false . See the documentation for any one of the mentioned classes and / or properties for more information and examples.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
ok i have a web page (csharp) and i calles a .dll written in foxpro to retrive information from a foxpro database but the problem is it caches the .dll and the database and any changes made outside of the webpage never get picked up by the webpag it looks at its cached copy of the database instead of going out and regetting the information
is there a way i can force it out of cache when i'm finished using it
chad
|
|
|
|
|
How are you caching it? Is the FoxPro code caching it? Surely there's settings or calls you can make to set up caching or even to disable it. If you're using the Page.Cache property, you should set up a CacheDepedency to invalidate it. There's also many other caching techniques for ASP.NET described in the .NET Framework SDK, as well as various articles in the ASP.NET Technical Articles[^] on MSDN.
If this doesn't quite answer your question, please be more specific about how you or your code is caching objects, and what is actually being cached.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Also, if it's caching the DLL, this should not be a problem. It's only loading and keeping the DLL in memory. The data being cached is the problem here. Either FoxPro is caching data, your DLL is caching data, or ASP.NET is caching data. If you actually change the ASP.NET web site (like recompiling or changing the Web.config file in the application's root directory), the web application is forced to restart, which will reload the DLL.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
its the web page cacheing the dll i use the dll for other programs and i don't have this cacheing proble and like you said i don't care if its cacheing the dll i care becasue its cacheing the database file
chad
|
|
|
|
|
The DLL is supposed to be cached for faster execution. Keep in mind that your web application using ASP.NET is an instance of an application with many threads that runs until 1) it changes and requires a restart, which the ASP.NET worker process does automatically, 2) you stop IIS, or 3) you shutdown/restart the server.
If your database is being cached, then either your DLL is causing the problem and should not cache data (in which case, it sounds like it's not multi-threaded and isn't expecting many requests from different threads) or you are not closing connections to your database. In either case, I'm pretty sure this is not the fault of ASP.NET. You're going to have to examine your DLL and make sure that it can handle multiple requests on different threads (I know FoxPro can, but it's been over a decade since I've worked with it so I can't help you there much) and that it doesn't cache data - at least not globally (i.e., for all threads).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
ok i checked the dll and it closes the connection but it seems like it's iis cacheing the dll and dbf because i worte a test.dll just to see and all it dose is when i call it it give me the first record in the database and closes the database but if i change the database outside of the web page it never pickes up those changes unless like you said i restart iis or restart my computer( i even tryed it as a webservice and it still gets cached) but when i use the dll on its own not in a webpage or webservice it works fine
thanks
chad
|
|
|
|
|
IIS or ASP.NET won't cache non-executable code unless you tell it otherwise. Keep in mind that IIS and ASP.NET (depending on how your DLL is loaded - most likely ASP.NET) will keep your DLL in memory so your DLL should not "load" the DBF. There are OLE DB providers, for instance, that create a connection with the DBF using ADO.NET (see the System.Data.OleDb classes). If all you're doing is executing queries on the DBF, then what's the extra DLL for? If that contains business rules and you don't want to redevelop the code for .NET (and there's nothing wrong with that), then make sure it establishes a connection the DBF instead of loading it into memory itself without persistence writes to the file. I guess it would help more to understand what exactly this DLL is, in what it's written, and what you need it for.
As I said though, IIS and ASP.NET would not load non-executable code into memory unless you tell it to (like I load an XML document into the cache in ASP.NET to build dynamic menus and have a cache dependency so that when the file changes the cache is invalidated and repopulated the next time the file is needed). If you're built an ISAPI library (in which case ASP.NET has nothing to do with it, but I add this for posterity), you can disable caching of extension handlers in the application configuration for a virtual application in IIS.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
this dll dose all my business rules and its very fast alot faster then if i did the same thing in csharp it access the dbf in the native visual foxpro language retrives the information it need to do my calculations updated and fields that need updating then closes the files and returns me a value
how to i force iis or asp.net to flush its cache because i know it one of them doing it when i test this from other apps. it works fine and it picks up my changes
chad
|
|
|
|
|
i have a boot disk that boots into 95 mode and brings me to the command prompt. i've made a console app in c# but when i run it it says 'cannot be run in dos mode'. what can i do to fix this?
thanks,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
For one, .NET does not work on Win95. Second, if you boot from a floppy disk on a supporting platform (like Win98), the CLR and the .NET Framework Class Library (FCL) at the very least must be loaded, and those definitely won't fit on a floppy disk. There's so many reasons why this won't work. You really need to read the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
then what would you suggest to write a w95 dos mode application?
thanks,
Rob
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
C, using old Win32 APIs from the Platform SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi,
im developing a system where it'll be running accross about four workstations, these four are all connected to a database server. my question is in C# how and where do i synchronize database operations, for example deletion, adding, modifying and searching.
also.. is there any theoratical document that shows the difference between Java n C#, i search the net but only to get one that was on syntactical differences(by Dare Obasanjo). Any other reading materials?
thx !!
CODER
|
|
|
|