View Full Version : Totally Unloading C#
CadDog
2010-05-03, 03:35 PM
I didn't know where to place this question so if there is a better place for it please move... Thanks
*****
I have a C# program a Augi member created for me.
I would like to be able to totally unload the program so that I can edit it
without needed to close AutoCAD...
Here is what it has now:
{
this.Close();
this.Dispose();
}
While this closes the program it doesn't unload it.
if I try to rebuild it, I can't until I close AutoCAD which
I loaded and opened the program on.
Right now it is only working on my station but
in the future I will like my user to access it and
use it but if anyone has it only I won't be able to edit it...
Is there an Unload like in VBA???
Here is how I do this in VBA:
(defun c:unloadQW ()
(Setvar "cmdecho" 0)
(vl-cmdf "vbaunload" (strcat vbaPath "LayerMaker.dvb"))
(Setvar "cmdecho" 1)
(princ)
)
Thanks for stopping by and reading my question.
*****
My Search Code:
caddogc#unload
Ed Jobe
2010-05-03, 04:06 PM
No, you can't unload a .net dll.
CadDog
2010-05-03, 08:36 PM
No, you can't unload a .net dll.
So how do you edit a program once people are using it...???
Can you over ride the existing .dll
(which I try but I was told I could not by the system)... :)
???
Ed Jobe
2010-05-03, 10:20 PM
So how do you edit a program once people are using it...???
Sounds like you're trying to have users run the dll from a network location, everyone accessing the same file?
CadDog
2010-05-03, 10:28 PM
Sounds like you're trying to have users run the dll from a network location, everyone accessing the same file?
That's right...
All my programs since AutoCAD 12 have worked that way...
Lisp like always and then VBA but now with VB or C# I don't know how to handle them.
Do I need to rethink how I put out the programs or apps for the user to access...???
dgorsman
2010-05-03, 10:29 PM
So how do you edit a program once people are using it...???
Can you over ride the existing .dll
(which I try but I was told I could not by the system)... :)
???
Do your development work offline, rather than on the file that the users are loading. Not that important with LISP, but more important with VBA and critical with .NET.
Once you have the functioning (and tested) DLL, you can push it to a common network location which is either CASPOL-enabled for users or read by a copy-local update routine. If necessary, you could have a scheduled task to do this unattended when nobody is around.
CadDog
2010-05-03, 11:05 PM
Do your development work offline, rather than on the file that the users are loading. Not that important with LISP, but more important with VBA and critical with .NET.
Once you have the functioning (and tested) DLL, you can push it to a common network location which is either CASPOL-enabled for users or read by a copy-local update routine. If necessary, you could have a scheduled task to do this unattended when nobody is around.
Wow... ???!!!!???
Looks like I seen this statement before...???
What if someone somewhere in the building leaves his station open with dll...???
Is that where the Read by a copy-local helps...???
Sorry for asking this simple question but
even my VBA worked live on the network because
I was able to totally unload once the user stopped using it...
(with the code shown above)
RobertB
2010-05-04, 12:13 AM
What if someone somewhere in the building leaves his station open with dll...???
Is that where the Read by a copy-local helps...???I would suggest the local cache approach. I even did that with my old VBA code because I hated waiting for someone to get out of AutoCAD or unload the DVB just so I could update it.
Our login script copies any updates to the cache so everyone gets the latest code when they login.
dgorsman
2010-05-04, 02:37 PM
Wow... ???!!!!???
Looks like I seen this statement before...???
What if someone somewhere in the building leaves his station open with dll...???
Is that where the Read by a copy-local helps...???
Sorry for asking this simple question but
even my VBA worked live on the network because
I was able to totally unload once the user stopped using it...
(with the code shown above)
If somebody leaves with AutoCAD running and I need to release something, their computer gets turned off. Theres no good reason to leave a computer on/locking up files. Save the work, turn off the computer, and go home.
Theres also the problem of people working while you are developing - what happens if something doesn't work properly the first time through? Or they need to use the function but you are not finished modifying it? Develop, then test, *then* roll out to the users. Its a couple of extra steps but well worth it.
CadDog
2010-05-04, 04:35 PM
There's no way to unload an assembly, but there is a way to
overwrite an assembly that's deployed on a network, without
requiring others using it to shut down.
See this document:
http://msdn.microsoft.com/en-us/library/ms404279.aspx
Unfortunately, since you don't have control over AutoCAD's
AppDomain, you can't use Assembly Shadow Copying
directly, but you can 'roll your own' version of it, using the
AppDomain's AssemblyResolve event, which fires when
.NET cannot locate an assembly in the search path. You
can build an assembly that handles this event, and when
it fires, you can do your own shadow copy of the assembly
that's needed, and load the copy rather than the source,
which allows you to update the source while others are
using it.
Thanks Tony,
I'm stepping a little out there since this is my first and only C# program using DLL...
Plus I didn't write it at all... :(
OK...!!! A LOT out there...
I understand the idea and it will take me a little time to really think it through...
I even thought of creating a few copies and placing them different directories and
having my AcadDoc.lsp select a new location for each day of the week.
This idea may help but I don't like having more then one version flowing around...
Again, let me think this new idea through...
Thanks for the light, Tony... :)
You can also just rename a DLL that people are using. For example, if you have a DLL named "foo.dll", just rename it to "foo_old.dll" and put the new "foo.dll" in its place. Then, once everyone has shut down Autocad, you'll be free to delete the "foo_old.dll". In some ways, this isn't as nice as using the login script, but it can be about as effective.
CadDog
2010-05-12, 05:17 PM
You can also just rename a DLL that people are using. For example, if you have a DLL named "foo.dll", just rename it to "foo_old.dll" and put the new "foo.dll" in its place. Then, once everyone has shut down Autocad, you'll be free to delete the "foo_old.dll". In some ways, this isn't as nice as using the login script, but it can be about as effective.
Thanks sinc,
I did think of that however that method only works when and IF everyone closes their AutoCAD.
I would like to fix on the fly as I do now with VBA and Lisp...
Old Dog thinking here... hahaha :)
Old Dog thinking here... hahaha :)
You need to learn new tricks, then.
CadDog
2010-05-12, 09:38 PM
You need to learn new tricks, then.
That's why I'm here...
:)
This board offers so much that sometime I can't even think of which way to go...
:(
I did think of that however that method only works when and IF everyone closes their AutoCAD.
I rename DLLs all the time while they are being used. I can't delete them, but I can rename them.
For example, somebody is using Foo.dll, so I can't delete it. I rename it to Foo_old.dll, and put the new Foo.dll in its place. The user who is using the DLL doesn't even notice. But the next time they start Autocad, they load the new Foo.dll. Eventually, all users shut down and restart Autocad, and I can delete Foo_old.dll.
Not as nice a solution in some respects as the login script, but it requires no setup. And as a benefit, users will get the new DLL the next time they startup Autocad. With the login script, the user doesn't get the latest version until after the next time they logout and log back in.
CadDog
2010-05-19, 08:20 PM
I rename DLLs all the time while they are being used. I can't delete them, but I can rename them.
For example, somebody is using Foo.dll, so I can't delete it. I rename it to Foo_old.dll, and put the new Foo.dll in its place. The user who is using the DLL doesn't even notice. But the next time they start Autocad, they load the new Foo.dll. Eventually, all users shut down and restart Autocad, and I can delete Foo_old.dll.
Not as nice a solution in some respects as the login script, but it requires no setup. And as a benefit, users will get the new DLL the next time they startup Autocad. With the login script, the user doesn't get the latest version until after the next time they logout and log back in.
WOW... Just tested this method...
That Works For Me...!!!
I thought since you can't delete it you couldn't do anything to the dll...
This is simple and easy and I will use this method...
Thanks sinc for making this clear to me...
:!:
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.