Click here to Skip to main content
15,890,579 members
Home / Discussions / C#
   

C#

 
QuestionRe: Is it possible to create instance aliases in C#? Pin
Skippums11-Dec-07 9:26
Skippums11-Dec-07 9:26 
GeneralRe: Is it possible to create instance aliases in C#? Pin
Luc Pattyn11-Dec-07 9:48
sitebuilderLuc Pattyn11-Dec-07 9:48 
GeneralFormat code for a decimal number. Pin
dbrenth11-Dec-07 7:37
dbrenth11-Dec-07 7:37 
GeneralRe: Format code for a decimal number. Pin
pmarfleet11-Dec-07 7:54
pmarfleet11-Dec-07 7:54 
QuestionReceiving Connection Error w/ SQL DB File on Remote/Hosting Server Pin
dboy22111-Dec-07 7:17
dboy22111-Dec-07 7:17 
GeneralClasses and references Pin
User 665811-Dec-07 6:42
User 665811-Dec-07 6:42 
GeneralRe: Classes and references Pin
Skippums11-Dec-07 6:59
Skippums11-Dec-07 6:59 
GeneralLoad assmebly into new appdomain from filename Pin
Josh Ryon11-Dec-07 6:19
Josh Ryon11-Dec-07 6:19 
Let's say I have an assembly whatever.dll. I have an app where I want to load that assembly dynamically at runtime (it implements an interface that I know about already) and all I have to go on is the filename. If I do this:

<br />
            Assembly assembly = Assembly.LoadFrom(@"C:\somecrazypath\bin\Debug\whatever.dll");<br />
            foreach (Type type in assembly.GetTypes())<br />
            {<br />
                if (type.GetInterface("IMyInterface") == null)<br />
                {<br />
                    continue;<br />
                }<br />
<br />
                // If it implements IMyInterface,<br />
                // create an instance of the object<br />
                object ibaseObject = Activator.CreateInstance(type);<br />
                LoadedModules.Add((IMyInterface)ibaseObject);<br />
            }<br />


Then it works great. I can handle events from the object in whatever.dll, and I have a reference to it that works as expected. However, that doesn't allow whatever.dll to have it's own config file, which is also a requirement. So in doing some research, it seems that if you load an object in it's own appdomain, then it can have it's own app.config (read here). So that seemed perfect, but the problem is that I just can't get the code to load right. If I do this:
<br />
AppDomainSetup ads = new AppDomainSetup();<br />
ads.PrivateBinPath += @"C:\somecrazypath\bin\Debug\";<br />
ads.ApplicationBase = @"C:\somecrazypath\bin\Debug\";<br />
ads.ConfigurationFile = @"C:\somecrazypath\bin\Debug\whatever.dll.config";<br />
AppDomain ad = AppDomain.CreateDomain("Whatever", null, ads);<br />
byte[] _assembly = loadFile(@"C:\somecrazypath\bin\Debug\whatever.dll");<br />
ad.Load(_assembly); //this line generates exception<br />


I get a filenotfound exception stating that it could not find whatever.dll or one of its dependencies. For the purposes of testing, I made sure that whatever.dll does not have any dependencies (no references other than System, System.Configuration, System.Data, and System.Xml) and I had it inherit MarshalByRefObject instead of my base class to eliminate that as a possible problem. I'm really at a loss as to why it can't seem to find the file. From reading online, it seems that the problem is because it is in a different path than the currently running appdomain, but I would have expected that setting the privatebinpath and the applicationbase on the new appdomain should have fixed that. I did find another report of the same problem here but the answer is incorrect. Passing the full path\filename to createinstanceandunwrap doesn't really fix it.

Has anyone run into this problem before?
GeneralRe: Load assmebly into new appdomain from filename Pin
Josh Ryon11-Dec-07 6:46
Josh Ryon11-Dec-07 6:46 
QuestionC# Deployment on Remote Machine [modified] Pin
Tiger_tom11-Dec-07 5:13
Tiger_tom11-Dec-07 5:13 
GeneralGarbage collector not freeing memory - honest! Pin
Judah Gabriel Himango11-Dec-07 4:48
sponsorJudah Gabriel Himango11-Dec-07 4:48 
GeneralRe: Garbage collector not freeing memory - honest! Pin
Luc Pattyn11-Dec-07 7:01
sitebuilderLuc Pattyn11-Dec-07 7:01 
GeneralRe: Garbage collector not freeing memory - honest! Pin
Judah Gabriel Himango11-Dec-07 7:55
sponsorJudah Gabriel Himango11-Dec-07 7:55 
GeneralRe: Garbage collector not freeing memory - honest! Pin
Luc Pattyn11-Dec-07 8:21
sitebuilderLuc Pattyn11-Dec-07 8:21 
GeneralRe: Garbage collector not freeing memory - honest! Pin
Judah Gabriel Himango11-Dec-07 9:14
sponsorJudah Gabriel Himango11-Dec-07 9:14 
GeneralRe: Garbage collector not freeing memory - honest! Pin
Pete O'Hanlon11-Dec-07 9:49
mvePete O'Hanlon11-Dec-07 9:49 
GeneralRe: Garbage collector not freeing memory - honest! Pin
Luc Pattyn11-Dec-07 9:52
sitebuilderLuc Pattyn11-Dec-07 9:52 
QuestionON_MESSAGE in C# Pin
PKR11-Dec-07 3:57
PKR11-Dec-07 3:57 
GeneralRe: ON_MESSAGE in C# Pin
Anthony Mushrow11-Dec-07 4:08
professionalAnthony Mushrow11-Dec-07 4:08 
GeneralRe: ON_MESSAGE in C# Pin
PKR11-Dec-07 5:08
PKR11-Dec-07 5:08 
GeneralObject cannot be cast from DBNull to other types. Pin
eyeseetee11-Dec-07 3:51
eyeseetee11-Dec-07 3:51 
GeneralRe: Object cannot be cast from DBNull to other types. Pin
Anthony Mushrow11-Dec-07 4:12
professionalAnthony Mushrow11-Dec-07 4:12 
GeneralRe: Object cannot be cast from DBNull to other types. Pin
Pete O'Hanlon11-Dec-07 5:26
mvePete O'Hanlon11-Dec-07 5:26 
GeneralPassing dynamic 2 dim float array in c# to unmanaged c++ dll Pin
f4hd11-Dec-07 3:14
f4hd11-Dec-07 3:14 
GeneralRe: Passing dynamic 2 dim float array in c# to unmanaged c++ dll Pin
m@u11-Dec-07 3:25
m@u11-Dec-07 3:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.