Yes this is possible, for strongly named assemblies, with an addition to the configuration section of the application's configuration file ( appname.exe.config ).
In this example we have an assembly StealthLib.dll which has been moved out of the applications's base directory to v:\Temp. Information about this new location is given in the dependentAssembly element where we must specify the assemblyIdentity and the codeBase.
Be really careful when editing the configuration file as errors are silently ignored. For example the assembly will not be found if the casing of publicKeyToken is changed to PublicKeyToken.
The Assembly Binding Log Viewer (FUSLOGVW.exe) which comes with the .NET SDK is very useful for resolving assembly loading problems as it will log all the locations that have been searched for dependent assemblies.
LOG: Appbase = file:///E:/VC/Projects/CP/AssemblyProbing/MainProg/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MainProg.exe
Calling assembly : MainProg, Version=1.0.4743.26012, Culture=neutral, PublicKeyToken=null.
LOG: This bind starts in default load context.
LOG: Using application configuration file: E:\VC\Projects\CP\AssemblyProbing\MainProg\bin\Debug\MainProg.exe.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: StealthLib, Version=220.127.116.11, Culture=neutral, PublicKeyToken=e0505f3b3553d5af
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///v:/Temp/StealthLib.dll.
LOG: Assembly download was successful. Attempting setup of file: v:\Temp\StealthLib.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: StealthLib, Version=18.104.22.168, Culture=neutral, PublicKeyToken=e0505f3b3553d5af
LOG: Binding succeeds. Returns assembly from v:\Temp\StealthLib.dll.
LOG: Assembly is loaded in default load context.
If you have say App.exe -> DllA -> DllB, i.e. DllA uses DllB and App does not directly reference DllB. If DllA and DllB have been moved out of the application base directory then App.exe.config must be edited to provide separate location information for both DllA and DllB and there is no assumption that DllB now resides in the same place as DllA.
Think of it like this: There is one process and the code in DllA executes in the context of that process. When code in DllA needs to call code residing in DllB then that assembly is loaded by 'the process' whose default locations are the GAC and the application base directory. Overrides to this default behaviour are on a per assembly basis.
Any information contained within *.dll.config is not read automatically and will be ignored.
a webBrowser object and then call the functions using the
I am in the process of developing a cloud backup software. The application is a desktop application developed using C#.
I need to add an option to stop/pause the backup if the computer was connected to a 3G network to save cost for the user.
I cannot seem to be able to find any example on how this can be achieved, there are some examples for Windows Phone and Windows Store Apps but I cannot find anything that can check if the connection type is a WiFi/Ethernet or 3G the latter is my main concern.
I tried a test application to enumerate the networks:
I have a problem with the code below....when I receive answer from my clients, if they are connected, ping class answer twice. The problem is that I have to put the answers in a richtextbox I would avoid to see some double entry !
Thanks in advance !!
foreach (string PC in primaColonnaPc)
Ping x = new Ping();
PingReply reply = x.Send(PC);
if (reply.Status == IPStatus.Success)
valore = PC + " OK\r";
f2.riceviDati = valore;
valore =("ATTENZIONE: " + PC + "ERROR\r");
f2.riceviDati = valore;
valore =("ATTENZIONE:" + PC + ": WS not found\r");
f2.riceviDati = valore;
Actually, you do know what's wrong: you're using an unassigned local variable. It will even tell you that strPLatitude is the culprit.
How to fix? Assign something to it, obviously. Most C# compile errors are easy like that.
You wanted a null array? Then make a null array: double strPLatitude = null;
That doesn't make the code work, I grant you, but it fixes this problem.
declared a null array but when i try to use this array to store my values
Reveals a deeper problem. You can't use something that doesn't exist. Like Richard wrote, "You must allocate some space to it before you can store anything in it". Your reply to him seems to imply you didn't really get it.
This is like saying "I have a place where a bookshelf should go but there isn't one there yet, why do things go wrong when I try to store books in it?"
Don't use something that doesn't exist. You need an actual bookshelf, not just a place where a bookshelf could go.
PIEBALDconsult suggest you use a List, you should probably do that. Be sure to Add[^] the items to the list, don't try to stuff them into positions that do not exist.
Im doing a big final project that manages a dive shop.
This application will have data base.
What im looking for is some example of solution that works with data base(connect to DB , SQL , Query) that i can take and modify it for my needs.
I understand that article is from 2007, but I'd completely disregard it. It was completely bad practice even "back then". Definitely is horrible practice today. Use a proper data access layer like EF, nHibernate, etc. At the very least, if you use barebones ADO.NET, you should not write queries in the C# code like that. Completely vulnerable to a script kiddie who knows SQL injection.
Last Visit: 31-Dec-99 18:00 Last Update: 23-Oct-14 23:48