Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
779 views
in Technique[技术] by (71.8m points)

.net - Can I make the default AppDomain use shadow copies of certain assemblies?

A short explanation of why I want to do this:

I am busy writing a plugin for Autodesk Revit Architecture 2010. Testing my plugin code is extremly cumbersome, as I have to restart Autodesk for each debug session, manually load a Revit project, click on the Add-Ins tab and then start my plugin. This is just taking too long.

I have written a second plugin that hosts an IronPython interpreter. This way, I can play around with the API provided by Revit. But eventually, the code has to be rewritten in C# - and debugged.

Easy, I thought: Just load the plugins DLL from the IronPython script and exercise it. This does work, but once loaded, I cannot recompile in Visual Studio, as the DLL is now loaded in Revits AppDomain.

Easy, I thought (with a little help from StackOverflow): Just load the DLL in a new AppDomain. Alas, the RevitAPI objects can't be marshaled to another AppDomain, as they don't extend MarshalByRefObject.

I think I might be onto something with shadow copies. ASP.NET seems to be doing this. But reading the documentation on MSDN, it seems I can only specify this when creating an AppDomain.

Can I change this for the current (default) AppDomain? Can I force it to use shadow copies of DLLs from a specific directory?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I don't know what you are trying to do but there are some deprecated methods to turn on ShadowCopy on the current AppDomain.

AppDomain.CurrentDomain.SetCachePath(@"C:Cache");
AppDomain.CurrentDomain.SetShadowCopyPath(AppDomain.CurrentDomain.BaseDirectory);
AppDomain.CurrentDomain.SetShadowCopyFiles();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...