Click here to Skip to main content
15,911,503 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Give to my program the possibility to detect if one of required assemblies is not found Pin
Dave Kreskowiak19-Mar-15 10:15
mveDave Kreskowiak19-Mar-15 10:15 
AnswerRe: Give to my program the possibility to detect if one of required assemblies is not found Pin
Eddy Vluggen19-Mar-15 10:47
professionalEddy Vluggen19-Mar-15 10:47 
GeneralRe: Give to my program the possibility to detect if one of required assemblies is not found Pin
dilkonika19-Mar-15 14:25
dilkonika19-Mar-15 14:25 
GeneralRe: Give to my program the possibility to detect if one of required assemblies is not found Pin
Eddy Vluggen19-Mar-15 23:48
professionalEddy Vluggen19-Mar-15 23:48 
GeneralRe: Give to my program the possibility to detect if one of required assemblies is not found Pin
Eddy Vluggen20-Mar-15 1:26
professionalEddy Vluggen20-Mar-15 1:26 
GeneralRe: Give to my program the possibility to detect if one of required assemblies is not found Pin
Dave Kreskowiak20-Mar-15 2:35
mveDave Kreskowiak20-Mar-15 2:35 
GeneralRe: Give to my program the possibility to detect if one of required assemblies is not found Pin
dilkonika20-Mar-15 7:20
dilkonika20-Mar-15 7:20 
GeneralRe: Give to my program the possibility to detect if one of required assemblies is not found Pin
Eddy Vluggen20-Mar-15 10:06
professionalEddy Vluggen20-Mar-15 10:06 
dilkonika wrote:
but I don't want that my application in a such scenario to hang and to be
difficult to close it. and of course I want a good messaging behavior to inform
the user about what is happening.
That is done using a loader, as explained. I've used the principle before, for an app that needed certification and one of the requirements was to ensure that the files were "as expected". It should recognize "any tampering". Easy with a loader and some hashing.

dilkonika wrote:
About the response , I read somewhere about
If you're only interested in a single kind of solution, please add it to the starting-post. If possible, with a hyperlink! Now, since you're not going to change your mind even if I say you cannot guarantee that your backups are not equally corrupted, here's your personalized example;

  1. Create a NEW solution, add a console-project
  2. Add a class-library and call it "ClassLibrary1".

Edit the class in the classlibrary to look like below;
C#
namespace ClassLibrary1
{
    public static class Class1
    {
        public static string Property1 { get { return "Hello From Class1"; } }
    }
}
Go to the console-app, and change the Program.cs to below;
C#
namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.AssemblyResolve += currentAppDomain_AssemblyResolve;

            externalTest();

            Console.ReadLine();
        }

        static System.Reflection.Assembly currentAppDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            Console.WriteLine("Assembly Resolve {0}", args.Name);

            return AppDomain.CurrentDomain.Load(File.ReadAllBytes(@"D:\Projects\ConsoleApplication8\ClassLibrary1\bin\Debug\Copy of ClassLibrary1.dll"));
        }

        static void externalTest()
        {
            Console.WriteLine(ClassLibrary1.Class1.Property1);
        }
    }
}


  1. Change the path in the above code to your own local folder.
  2. Put a reference from the Console-app to ClassLibrary1.
  3. Build.
  4. Make a copy of the file "ClassLibrary1.dll", rename it to "Copy of ClassLibrary1.dll" (but keep it in that folder, otherwise you'd need to rebuild to update the folder-location in the code)
  5. Remove the file "ClassLibrary1.dll" from the debug-folders from BOTH projects.
  6. Right-click on the project, choose "Unload"
  7. Hit F5 key. It'll say the static linked file ain't there. Ignore it and run the last build, there's no updated code anyway.
  8. You'll be taken into the debugger and can see how resolving works.


DO read MSDN on the topic, as it contains some things that you will NEED. One particular warning I'd like to point out;
The event handler can return a different version of the assembly than the version that was requested.

Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]

Questionhow to create a text screen saver by readind and displaying the text file Pin
Member 1153747318-Mar-15 20:11
Member 1153747318-Mar-15 20:11 
AnswerRe: how to create a text screen saver by readind and displaying the text file Pin
Eddy Vluggen19-Mar-15 10:50
professionalEddy Vluggen19-Mar-15 10:50 
QuestionDetecting beat from audio input Pin
MBV-Media16-Mar-15 2:06
MBV-Media16-Mar-15 2:06 
AnswerRe: Detecting beat from audio input Pin
Eddy Vluggen16-Mar-15 10:06
professionalEddy Vluggen16-Mar-15 10:06 
GeneralRe: Detecting beat from audio input Pin
MBV-Media17-Mar-15 2:26
MBV-Media17-Mar-15 2:26 
QuestionSuddenly the Form.Shown event doesn't fire anymore Pin
dilkonika15-Mar-15 17:48
dilkonika15-Mar-15 17:48 
AnswerRe: Suddenly the Form.Shown event doesn't fire anymore Pin
CHill6016-Mar-15 6:14
mveCHill6016-Mar-15 6:14 
GeneralRe: Suddenly the Form.Shown event doesn't fire anymore Pin
dilkonika16-Mar-15 7:24
dilkonika16-Mar-15 7:24 
GeneralRe: Suddenly the Form.Shown event doesn't fire anymore Pin
CHill6016-Mar-15 7:26
mveCHill6016-Mar-15 7:26 
GeneralRe: Suddenly the Form.Shown event doesn't fire anymore Pin
dilkonika16-Mar-15 7:31
dilkonika16-Mar-15 7:31 
SuggestionRe: Suddenly the Form.Shown event doesn't fire anymore Pin
Richard Deeming16-Mar-15 7:42
mveRichard Deeming16-Mar-15 7:42 
GeneralRe: Suddenly the Form.Shown event doesn't fire anymore Pin
dilkonika16-Mar-15 7:47
dilkonika16-Mar-15 7:47 
GeneralRe: Suddenly the Form.Shown event doesn't fire anymore Pin
Richard Deeming16-Mar-15 7:51
mveRichard Deeming16-Mar-15 7:51 
GeneralRe: Suddenly the Form.Shown event doesn't fire anymore Pin
dilkonika16-Mar-15 8:03
dilkonika16-Mar-15 8:03 
GeneralRe: Suddenly the Form.Shown event doesn't fire anymore Pin
dilkonika17-Mar-15 9:08
dilkonika17-Mar-15 9:08 
GeneralRe: Suddenly the Form.Shown event doesn't fire anymore Pin
Richard Deeming17-Mar-15 9:44
mveRichard Deeming17-Mar-15 9:44 
GeneralRe: Suddenly the Form.Shown event doesn't fire anymore Pin
dilkonika17-Mar-15 11:12
dilkonika17-Mar-15 11:12 

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.