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

AppDomain.CurrentDomain.AppendPrivatePath Depreciated?

What should I do instead of this:
AppDomain.CurrentDomain.AppendPrivatePath(Path.Get DirectoryName(System.Windows.Forms.Application.Exe cutablePath)
+ @"\plugins");
now that AppDomain.CurrentDomain.AppendPrivatePath is depreciated?
Dec 1 '05 #1
5 10972
You need to configure the private paths before the appdomain has been
created. You can do it by adding entries to the app.config file (for the
entire app or for each appdomain that is created by the app), or by adding
entries to the appdomain setup information that is used to construct
secondary appdomains. You can also subscribe to the
AppDomain.AssemblyResolve event and manually load assemblies using LoadFrom
(or one of its variants)....the disadvantage is assemblies loaded using
Loadxxx are in a different fusion load context then assemblies that the
runtime resolves automatically.

I've lobbied (unsuccessfully) for this API to remain as I use it in v1.1.

"Benny Raymond" <be***@pocketrocks.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
What should I do instead of this:
AppDomain.CurrentDomain.AppendPrivatePath(Path.Get DirectoryName(System.Windows.Forms.Application.Exe cutablePath)
+ @"\plugins");
now that AppDomain.CurrentDomain.AppendPrivatePath is depreciated?

Dec 1 '05 #2
Since loading my plugins in a seperate domain wasn't sufficent for what
my app required, here's what I ended up doing. Please let me know if
i'm going about anything wrong. - Also, I can't figure out how to make
my plugins automatically compile into the plugins directory instead of
the main output one - please let me know if you know how to do this
(right now i'm using the post compile event)

I changed my main form so that it loads up as a stub executable, so my
exe ends up being really small and just consists of this:

namespace APPNAME
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
setup.PrivateBinPath = @"\,\Plugins";
setup.ApplicationName = "APPNAME";
AppDomain appDom =
AppDomain.CreateDomain("APPNAME",null,setup);
appDom.CreateInstanceFromAndUnwrap("APPNAME.Contai ner.dll",
"APPNAME.Container.Program");
}

}
}

then, I start buliding my app as normal within the APPNAME.Container dll
- instead of your normal program.cs file it ends up looking something
like this:

namespace APPNAME.Container
{
[Serializable]
class Program
{
public Program()
{
Application.Run(new Form1());
}
}
}
Dec 1 '05 #3
How do you configure private paths in the app.config file? Do those
paths have to be absolute? (i hope not)

~Benny
Dec 1 '05 #4
This links to the docs on the schema required for the app.config files.

http://msdn.microsoft.com/library/de...ingsschema.asp

The <probing> element adds subdirectories to the search path.

Your .config file will have a section that looks like this...

<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin;bin2\subbin;bin3"/>
</assemblyBinding>
</runtime>
</configuration>

where each path component is a subdirectory under the application base
directory; delimit each relative path with a semi-colon. The paths are all
relative to the base directory.

This has a similar effect to adding these subdirectories using the
AppendPrivateBinPath API.

"Benny Raymond" <be***@pocketrocks.com> wrote in message
news:Ok**************@TK2MSFTNGP11.phx.gbl...
How do you configure private paths in the app.config file? Do those paths
have to be absolute? (i hope not)

~Benny

Dec 2 '05 #5
The line of code:

setup.PrivateBinPath = @"\,\Plugins";

does not appear correct. Each separate relative path should be delimited
with a semi-colon, not a comma, and the relative path "\" does nothing so
far as I can tell. Also, you do not need to pre-pend a leading backslash. I
think you could replace that LOC with this...

setup.PrivateBinPath = @"Plugins";

Also, if the only thing your loader does is specify a relative search path
you could more easily add a <probing> element (see my other reply) to you
app.config file and not need the loader at all.
"Benny Raymond" <be***@pocketrocks.com> wrote in message
news:ul**************@TK2MSFTNGP14.phx.gbl...
Since loading my plugins in a seperate domain wasn't sufficent for what my
app required, here's what I ended up doing. Please let me know if i'm
going about anything wrong. - Also, I can't figure out how to make my
plugins automatically compile into the plugins directory instead of the
main output one - please let me know if you know how to do this (right now
i'm using the post compile event)

I changed my main form so that it loads up as a stub executable, so my exe
ends up being really small and just consists of this:

namespace APPNAME
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
setup.PrivateBinPath = @"\,\Plugins";
setup.ApplicationName = "APPNAME";
AppDomain appDom =
AppDomain.CreateDomain("APPNAME",null,setup);
appDom.CreateInstanceFromAndUnwrap("APPNAME.Contai ner.dll",
"APPNAME.Container.Program");
}

}
}

then, I start buliding my app as normal within the APPNAME.Container dll -
instead of your normal program.cs file it ends up looking something like
this:

namespace APPNAME.Container
{
[Serializable]
class Program
{
public Program()
{
Application.Run(new Form1());
}
}
}

Dec 2 '05 #6

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

Similar topics

0
by: Eli Abitbol | last post by:
Hi All I am using a few Microsoft application blocks in our winforms applications I am having problem with the Microsoft.ApplicationBlocks.ExceptionManagement components The samples for...
0
by: Matt Calhoon | last post by:
Hi there, I have a web application that I need to move to a new webfarm. This application uses AppDomain.CurrentDomain.BaseDirectory to call up the base path (D:\content\clientwebsiteroot\) when...
0
by: Matt Calhoon | last post by:
Hi there, Im in the process of moving 200 odd websites to a new webfarm. This webfarm consists of several web servers that access a separate dedicated hardware storage device (Network Appliance...
0
by: GrantS | last post by:
To ensure my C# Winforms application can only have one instance running, I am using the code below: string proc=Process.GetCurrentProcess().ProcessName; // get the list of all processes by that...
1
by: George Nevsky | last post by:
My ASP.Net application installed in IIS virtual folder which points to some shared folder on network. Everything works fine except AppDomain.CurrentDomain.BaseDirectory method. It returns...
0
by: Luis Esteban Valencia | last post by:
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal) Dim authuser As WindowsPrincipal = CType(System.Threading.Thread.CurrentPrincipal, WindowsPrincipal) Dim strUserName As...
7
by: JJ | last post by:
Hi, What's the equivalent for AppDomain.CurrentDomain.BaseDirectory in asp.net? Trying to access web app directory for reading and writing xml files. Thanks, JJ
1
by: pack | last post by:
What're the meaning of "App domain" and "Current Domain" in appdomain.CurrentDomain.UnhandledException?
0
by: Gabriel Ferrarini | last post by:
The following code show me all assemblies attached to the project. ================================= For Each asm In AppDomain.CurrentDomain.GetAssemblies() MessageBox.Show(asm.Location) ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.