Results 1 to 39 of 39

Thread: Start embedded Exe from tempfolder

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Exclamation Start embedded Exe from tempfolder

    is there a way to write everything embedded to a tempfolder not just dlls , everything in resources and assign a process to a button from there ?
    Last edited by fokeiro; Jul 5th, 2011 at 05:08 PM.

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Add dll files to embedded resources

    Take a look at this.

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    This is more or less what im trying to accomplish.

    http://www.megaupload.com/?d=X734SNDQ


    My question is now how can i get all the files dlls texts project files and compile it into one single exe that wont require installation just execute my form and run it and how can i stop what happens on the video which when i open the embedded program it copy itself to the drive and stay there after i close it cause i dont mind putting aall dlls in project folder but when i gi e my exe to someone is just one file executable and with working embedded program
    Last edited by fokeiro; Jun 30th, 2011 at 12:23 PM.

  4. #4
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Add dll files to embedded resources

    I'm not downloading files that contain executables. Did you read the thread? The first reply is exactly what you have to do. Google is your best bet. This is the second result of Googling "embedding dlls vb.net".

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    What about stopping the exe from writing itself to the drive? Ill post another video with the app in the link so u know what i mean and yeah i read it but how can i set it up and what i want to do is fuze everything not just dlls to my main form
    Last edited by fokeiro; Jun 30th, 2011 at 01:51 PM.

  6. #6
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Add dll files to embedded resources

    You can embed literally any type of file into your .exe. It is not limited to dlls. I don't understand what this means:
    What about stopping the exe from writing itself to the drive?
    Writing itself...? Are you talking about when it writes the dll out? You might be able to write it into memory and then read it. But if you do it as a temp file in the temp folder, the user won't know.

  7. #7
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: Add dll files to embedded resources

    When you write the embedded resource to disk, you need to hold on to the file path where it is written to (store it in a global or shared variable that can be accessed elsewhere). You then handle the application.shutdown event and delete the file there.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  8. #8

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    Yeah as u see in the video in my folder i delete the exe the open my form press button to execute the embedded form and it works fine but when i close my form
    It stay there and i need to delete again wyat would be the steps to write it to a temp folder or path that would be deleted when i close my form since the point is the user cant use the software if hes not using my form

  9. #9
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Add dll files to embedded resources

    If you’re true intent is to simply give a user one executable assuming the correct .NET Framework is installed then why not simply embed the DLL/assembly as an embedded resource and allow .NET to load the DLL/assembly if it is missing. Why hide this file if you have the rights to use it?

    The attached solution has two projects. The first project is a simple class library with a single class Customer. The second Windows form project references the class library and creates a list of customers, which are displayed in a DataGridView.

    If the class library DLL is not located when your application requires it the following code will extract the DLL from the primary assembly and load it.

    To test it out, build the solution then remove the DLL from the Windows form project directory followed by running the Windows form executable. The DLL will be extracted from the code in ResolveEventHandler. Of course instead of the logic in ResolveEventHandler you could find other methods but I think this works well.

    Hook into AssemblyResolve, find the customer dll and load it.
    Code:
    Public Sub New()
        InitializeComponent()
        AddHandler AppDomain.CurrentDomain.AssemblyResolve, AddressOf ResolveEventHandler
    End Sub
    
    Function ResolveEventHandler(ByVal sender As Object, ByVal args As ResolveEventArgs) As Assembly
        Dim ExecutingAssemblies As Assembly = Assembly.GetExecutingAssembly()
    
        Dim ReferencedAssmbNames() As AssemblyName = ExecutingAssemblies.GetReferencedAssemblies()
    
        Dim AssemblyName As AssemblyName
        Dim MyAssembly As Assembly = Nothing
    
        For Each AssemblyName In ReferencedAssmbNames
            'Look for the assembly names that have raised the "AssemblyResolve" event.
            If (AssemblyName.FullName.Substring(0, AssemblyName.FullName.IndexOf(",")) = args.Name.Substring(0, args.Name.IndexOf(","))) Then
    
                Dim TempAssemblyPath As String
                TempAssemblyPath = IO.Path.Combine(Application.StartupPath, args.Name.Substring(0, args.Name.IndexOf(",")) & ".dll")
                My.Resources.CustomerDemo.FileSave(My.Application.CustomerDllFileName)
                Application.DoEvents()
    
                'Load the assembly from the specified path. 
                MyAssembly = Assembly.LoadFrom(TempAssemblyPath)
                Exit For
            End If
        Next
    
        Return MyAssembly
    
    End Function
    Support Name of the DLL which is embedded
    Code:
    Namespace My
        Partial Friend Class MyApplication
            Public ReadOnly Property CustomerDllFileName() As String
                Get
                    Return IO.Path.Combine(My.Application.Info.DirectoryPath, "CustomerDemo.dll")
                End Get
            End Property
        End Class
    End Namespace
    Used to extract embedded DLL
    Code:
    <System.Runtime.CompilerServices.Extension()> _
    Public Sub FileSave(ByVal BytesToWrite() As Byte, ByVal FileName As String)
        If IO.File.Exists(FileName) Then
            IO.File.Delete(FileName)
        End If
    
        Dim FileStream As New System.IO.FileStream(FileName, System.IO.FileMode.OpenOrCreate)
        Dim BinaryWriter As New System.IO.BinaryWriter(FileStream)
    
        BinaryWriter.Write(BytesToWrite)
        BinaryWriter.Close()
        FileStream.Close()
    End Sub
    References
    ResolveEventHandler Delegate
    Unload Assemblies From an Application Domain
    Attached Files Attached Files

  10. #10

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    o couldnt open it in visual basic 2010 , ok a few questions namespace my what si supposed to go there

    this is my project of u can download it and put that code in there so i can see how it works i appreciated it, the site wont let me upload more than 500kb


    http://www.megaupload.com/?d=C1MRXQN4


    im uploading a video know when i finish u see what i need

  11. #11
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Add dll files to embedded resources

    Quote Originally Posted by fokeiro View Post
    o couldnt open it in visual basic 2010 , ok a few questions namespace my what si supposed to go there

    this is my project of u can download it and put that code in there so i can see how it works i appreciated it, the site wont let me upload more than 500kb


    http://www.megaupload.com/?d=C1MRXQN4


    im uploading a video know when i finish u see what i need
    What happened when you attempted to open the solution? There is nothing in either project within the solution that VS2010 can not handle. If you can supply specific error messages than we can get the solution loaded for you.

  12. #12

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    ok managed to open it how can i use this ??? what would be the codes to use and how i can create all those things that i dont have like mynamespace.vb and such


    this is my problem and then what i want to accomplish


    http://www.youtube.com/watch?v=u1ZBJ9ybzBY
    Last edited by fokeiro; Jun 30th, 2011 at 07:16 PM.

  13. #13
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Add dll files to embedded resources

    Quote Originally Posted by fokeiro View Post
    ok managed to open it how can i use this ??? what would be the codes to use and how i can create all those things that i dont have like mynamespace.vb and such


    this is my problem and then what i want to accomplish


    http://www.youtube.com/watch?v=u1ZBJ9ybzBY
    Before attempting this in your project learn what I did and understand it then do it in your project. If you did examine my project first you would see that the MyNamespace.vb file is there, you need to add it to your project and change the DLL name.

    Bottom line, take your time and do not rush the learning process.

  14. #14

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    do i just add file or do i add as resource ok i copied over mynamespace and resourcesextensions , replaced with dll name in mynamespace , i know in resourcesextensions i need to repalce soemthing but which parts ?


    update ok i did this and now when i put my exe in another pc the program open up but now it copy the exe and the dll to whereever my exe is. man im going on vacation tomorrow and i will be away from my pc for days i just want to get this figure out so by the time i come back i cant start working >.>


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim data() As Byte = My.Resources.JungleFlasher
    Dim file As New System.IO.FileStream("JungleFlasher.exe", IO.FileMode.Create)
    file.Write(data, 0, data.Length)
    file.Close()
    ' Run the Calc program named zzzz
    Dim p As New Process
    p.StartInfo.FileName = "JungleFlasher.exe"
    p.Start()

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim data() As Byte = My.Resources.libusb0
    Dim file As New System.IO.FileStream("libusb0.dll", IO.FileMode.Create)
    file.Write(data, 0, data.Length)
    file.Close()
    End Sub
    End Class
    Last edited by fokeiro; Jun 30th, 2011 at 09:11 PM.

  15. #15

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    is there a way i can make the two files that gets copy , so they copy to the temp folder in C drive which everyone has ? thsi is basically what i need
    But if you do it as a temp file in the temp folder


    will this work for what im trying to do ?

    Private Sub installFiles()

    Dim resFiles() As String = Application.ResourceAssembly.GetManifestResourceNames

    For Each resFile As String In resFiles
    If resFile.EndsWith("7za.exe") Then
    Dim tmpFile As String = IO.Path.Combine(IO.Path.GetTempPath, IO.Path.GetTempFileName)
    if ExtractEmbeddedResourcefile then(Application.ResourceAssembly.GetManifestResourceStream(resFile), tmpFile)
    debug.writeline(tmpFile) 'do something with the file name here (like start your process)
    end if
    'delete file when done
    IO.File.Delete(tmpFile)


    End If
    Next

    End Sub

    Private Function ExtractEmbeddedResourcefile(ByVal resStream As IO.Stream, ByVal OutFilename As String) As Boolean

    Try

    If IO.File.Exists(OutFilename) Then
    IO.File.Delete(OutFilename)
    End If

    Dim count As Integer = CType(resStream.Length, Integer) - 1
    Dim buffer(count) As Byte
    resStream.Read(buffer, 0, count + 1)

    Using fs As New FileStream(OutFilename, FileMode.Create)
    With fs
    .Write(buffer, 0, count + 1)
    .Flush()
    .Close()
    End With
    End Using

    Return CBool(IO.File.Exists(OutFilename))
    Catch ex As Exception
    Return False
    End Try
    Return False
    End Function

    or can this be applied to exes

    ake a look at this if you want to extract and run a .msi file:

    1
    Private Shared Function Extract(ByVal Path As String, ByVal RunIn As String) As Process
    2
    My.Computer.FileSystem.WriteAllBytes(My.Resources.Installer)
    3
    Dim Inf As New ProcessStartInfo
    4
    Inf.FileName = Path
    5
    Inf.WorkingDirectory = RunIn
    6
    Dim Prc As Process = Process.Start(Inf)
    7
    Return Prc
    8
    End Function


    And to use it:

    1
    Dim InstPrc As Process = Extract(My.Computer.FileSystem.CurrentDirectory & "\Installer.msi", My.Computer.FileSystem.SpecialDirectories.MyDocuments)


    Finally to delete the temporary file:

    1
    My.Computer.FileSystem.DeleteFile(My.Computer.FileSystem.CurrentDirectory & "\Installer.msi")
    Last edited by fokeiro; Jul 1st, 2011 at 07:26 AM.

  16. #16
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Add dll files to embedded resources

    From what I am, observing from you is that you are rushing into this without taking time to learn from the recommendations given to you. In addition, you said in the beginning that you were looking at embedding DLL files and now from the code above working with embedded executable files which to me seems suspicious in nature even though the purpose was to give a one file solution must applications do not need other executables.

    Below is a prime example that you are rushing in that this is not something that will compile.

    Code:
    if ExtractEmbeddedResourcefile then(Application.ResourceAssembly.GetManifestResourceStream(resFile), tmpFile)
    Again, if you want assistance here you need to take the time and work thru the task and then show us what you have done using proper code tags for this forum rather than wrap code in quotes.

    Please do not send me private messages either, if you have a question ask it here.

  17. #17

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    Well i work fot a collection law office and we will be using exe and dll of softwares designed just for us, i manage to get the dll and exe working from just my form i just need a way to write it instead of where my exe is lets say desktp/newfolder/ myform.exe to the tempfolder of windows or to ram then delete when i close my form so our collectors dont have acccess to the softwares if they dont use our form

  18. #18
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Add dll files to embedded resources

    Quote Originally Posted by fokeiro View Post
    Well i work fot a collection law office and we will be using exe and dll of softwares designed just for us, i manage to get the dll and exe working from just my form i just need a way to write it instead of where my exe is lets say desktp/newfolder/ myform.exe to the tempfolder of windows or to ram then delete when i close my form so our collectors dont have acccess to the softwares if they dont use our form
    With that said I believe you are heading in the wrong direction, instead look at obfuscation along with perhaps registration of the software and having the users sign an agreement to usage of said software. There is no reason to make an executable with embedded files as you are seeking to do.

    http://www.google.com/search?q=obfus...rlz=1I7WZPA_en

  19. #19

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    also doing another project for me is that i dont want to be installing software when i just can run myform.exe lets say from a flash drive that i can carry around Eo if i send it to someone they dont have to install it either

    In post 14 i showed u what i have so far , is that the right way to go and will this works with several exe an dll a set for each?
    Last edited by fokeiro; Jul 1st, 2011 at 09:19 AM.

  20. #20
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Add dll files to embedded resources

    Quote Originally Posted by fokeiro View Post
    In post 14 i showed u what i have so far , is that the right way to go and will this works with several exe an dll a set for each?
    If it works and at a decent speed than go with it.

  21. #21

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    But my problem is how can i stop it from write the resources to wherever my form.exe is and write it to a specific folder let say i give u my form when u execute it it write the embedded exe and dll to c:/windows/temp and either stay there for future executions to load faster of just delete after close form

  22. #22
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Add dll files to embedded resources

    Quote Originally Posted by fokeiro View Post
    But my problem is how can i stop it from write the resources to wherever my form.exe is and write it to a specific folder let say i give u my form when u execute it it write the embedded exe and dll to c:/windows/temp and either stay there for future executions to load faster of just delete after close form
    Not all users have access to the Windows Temp folder. You could place it under this folder.

    Code:
    System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

  23. #23

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    How can i add this to my coding? That folder sounds good btw i really apreciate ur help a lot
    Last edited by fokeiro; Jul 1st, 2011 at 10:40 AM.

  24. #24
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Add dll files to embedded resources

    Quote Originally Posted by fokeiro View Post
    How can i add this to my coding? That folder sounds good btw i really apreciate ur help a lot
    What is presented below was tested (using VS2008 which means that it will work with VS2010 under Windows Vista) fully to react to one single DLL file not present, not more than one. If there is more than one see my comment at the end of this post.

    Using the original VS2008 project I supplied the following shows how to create the folder where you want the DLL file to exists and be loaded when missing.

    MyNamespace.vb contents. You need to decided the DLL name in CustomerDllFileName and DllFolder both shown in red below
    Code:
    Namespace My
        Partial Friend Class MyApplication
            Public ReadOnly Property CustomerDllFileName() As String
                Get
                    Return "CustomerDemo.dll"
                End Get
            End Property
            Public ReadOnly Property DllFolderExists() As Boolean
                Get
                    Return IO.Directory.Exists(DllFolder)
                End Get
            End Property
            Public ReadOnly Property DllFolder() As String
                Get
                    Return IO.Path.Combine(System.Environment _
                                  .GetFolderPath(Environment _
                                  .SpecialFolder.CommonApplicationData), "MyFolder")
                End Get
            End Property
            Public ReadOnly Property CustomerFolderAndFileName() As String
                Get
                    Return IO.Path.Combine(DllFolder, CustomerDllFileName)
                End Get
            End Property
        End Class
    End Namespace
    Resolver.vb contents, comments in green point to the special properties under My.Application in MyNamespace.vb
    Code:
    Imports System.Reflection
    ''' <summary>
    ''' * Original version placed the needed DLL in the application startup folder.
    ''' * New version places the DLL in My.Application.DllFolder folder
    ''' </summary>
    ''' <remarks></remarks>
    Module Resolver
        ''' <summary>
        ''' This handler is called only when the common language runtime tries to bind to the assembly and fails.        
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <param name="args"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Function ResolveEventHandler(ByVal sender As Object, ByVal args As ResolveEventArgs) As Assembly
            Dim ExecutingAssemblies As Assembly = Assembly.GetExecutingAssembly()
    
            Dim ReferencedAssembliesNames() As AssemblyName = ExecutingAssemblies.GetReferencedAssemblies()
            Dim AssemblyName As AssemblyName
            Dim MyAssembly As Assembly = Nothing
    
            For Each AssemblyName In ReferencedAssembliesNames
                'Look for the assembly names that have raised the "AssemblyResolve" event.
                If (AssemblyName.FullName.Substring(0, AssemblyName.FullName.IndexOf(",")) = args.Name.Substring(0, args.Name.IndexOf(","))) Then
    
                    ' Build path to place DLL under Program Data folder
                    Dim TempAssemblyPath As String = _
                        IO.Path.Combine( _
                            My.Application.DllFolder, args.Name.Substring(0, args.Name.IndexOf(",")) & ".dll")
    
                    ' Make sure the folder exists
                    If Not My.Application.DllFolderExists Then
                        IO.Directory.CreateDirectory(My.Application.DllFolder)
                    End If
    
                    ' Copy DLL to our special folder
                    My.Resources.CustomerDemo.FileSave(My.Application.CustomerFolderAndFileName)
                    Application.DoEvents()
    
                    'Load the assembly from the specified path, in this case under Program Data
                    MyAssembly = Assembly.LoadFrom(TempAssemblyPath)
                    Exit For
                End If
            Next
    
            Return MyAssembly
    
        End Function
    
    End Module
    If you need to work with more than one DLL missing you will need to work that out in Function ResolveEventHandler by checking the base assembly name in the If statement shown below and then react to that in the FileCopy procedure.


    Code:
    For Each AssemblyName In ReferencedAssembliesNames
        If (AssemblyName.FullName.Substring(0, AssemblyName.FullName.IndexOf(",")) = args.Name.Substring(0, args.Name.IndexOf(","))) Then

  25. #25

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    but a few exe each with 1 dll i still ahve to code one for each right ? and also if i add resolver.vb to my project from the one u gave me i just add > existing file > compile or as resource too ?

  26. #26

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    ok this is mynamespace.vb

    should i rename it or mynamespace.vb is fine ? , this the coding

    vb Code:
    1. Namespace My
    2.     Partial Friend Class MyApplication
    3.         Public ReadOnly Property CustomerDllFileName() As String
    4.             Get
    5.                 Return "libusb0.dll"
    6.             End Get
    7.         End Property
    8.         Public ReadOnly Property DllFolderExists() As Boolean
    9.             Get
    10.                 Return IO.Directory.Exists(DllFolder)
    11.             End Get
    12.         End Property
    13.         Public ReadOnly Property DllFolder() As String
    14.             Get
    15.                 Return IO.Path.Combine(System.Environment _
    16.                               .GetFolderPath(Environment _
    17.                               .SpecialFolder.CommonApplicationData), "MyFolder")
    18.             End Get
    19.         End Property
    20.         Public ReadOnly Property CustomerFolderAndFileName() As String
    21.             Get
    22.                 Return IO.Path.Combine(DllFolder, CustomerDllFileName)
    23.             End Get
    24.         End Property
    25.     End Class
    26. End Namespace


    now how can i import into resolver.vb , if i build like this still write the dll and the exe to the folder where myform.exe is and can i use the same for my exe so it dont show where my form.exe is

  27. #27

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    highlighted d parts are the one i have problems with idk if i did it correctly

    Dim TempAssemblyPath As String (_
    IO.Path.Combine( _
    ' Copy DLL to our special folder
    My.Resources.libusb0.FileSave(My.Application.DllFolder)
    Application.DoEvents()


    i dont know what to put in these 3 >.>

    Code:
    Imports System.Reflection
    ''' <summary>
    ''' * Original version placed the needed DLL in the application startup folder.
    ''' * New version places the DLL in My.Application.DllFolder folder
    ''' </summary>
    ''' <remarks></remarks>
    Module Resolver
        ''' <summary>
        ''' This handler is called only when the common language runtime tries to bind to the assembly and fails.        
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <param name="args"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Function ResolveEventHandler(ByVal sender As Object, ByVal args As ResolveEventArgs) As Assembly
            Dim ExecutingAssemblies As Assembly = Assembly.GetExecutingAssembly()
    
            Dim ReferencedAssembliesNames() As AssemblyName = ExecutingAssemblies.GetReferencedAssemblies()
            Dim AssemblyName As AssemblyName
            Dim MyAssembly As Assembly = Nothing
    
            For Each AssemblyName In ReferencedAssembliesNames
                'Look for the assembly names that have raised the "AssemblyResolve" event.
                If (AssemblyName.FullName.Substring(0, AssemblyName.FullName.IndexOf(",")) = args.Name.Substring(0, args.Name.IndexOf(","))) Then
    
                    ' Build path to place DLL under Program Data folder
                    Dim TempAssemblyPath As String = Environment _
                                  .SpecialFolder.CommonApplicationData
                        IO.Path.Combine( _
                            My.Application.DllFolder, args.Name.Substring(0, args.Name.IndexOf(",")) & ".dll")
    
                    ' Make sure the folder exists
                    If Not My.Application.DllFolderExists Then
                        IO.Directory.CreateDirectory(My.Application.DllFolder)
                    End If
    
                    ' Copy DLL to our special folder
                    My.Resources.libusb0.FileSave(My.Application.DllFolder)
                    Application.DoEvents()
    
                    'Load the assembly from the specified path, in this case under Program Data
                    MyAssembly = Assembly.LoadFrom(TempAssemblyPath)
                    Exit For
                End If
            Next
    
            Return MyAssembly
    
        End Function
    
    End Module
    Last edited by fokeiro; Jul 1st, 2011 at 03:11 PM.

  28. #28

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    Did i do mynqmespace correctly?

  29. #29
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Add dll files to embedded resources

    Quote Originally Posted by fokeiro View Post
    Did i do mynqmespace correctly?
    Is it working? If yes then you did it right and if it does not work then you need to work on fixing it.

  30. #30

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    No is not yet since i cant figure out how to edit resolver.vb to adjust it to mynamespace properties, following the mynamespace coding which parts i import into the resolver to make it work and does this works for the exe too since is not just the dll that is writing to where form.Exe is but the embedded exe is too

  31. #31
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Add dll files to embedded resources

    Quote Originally Posted by fokeiro View Post
    No is not yet since i cant figure out how to edit resolver.vb to adjust it to mynamespace properties, following the mynamespace coding which parts i import into the resolver to make it work and does this works for the exe too since is not just the dll that is writing to where form.Exe is but the embedded exe is too
    Follow my example which does not import into the resolver code. What I gave you was a template to use as is for one DLL. I told you if you have more than one embedded assembly, in this case DLL then embed them, leave the code as presented and test. If this does not work explain specifically what is not working. If there an exception thrown then use a Try/Catch statement, in the catch write Console.WriteLine(ex.Message) and when an triggered copy (along with code which causes the exception) into you reply.

  32. #32

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    So resolve.vb i just leave alone the way u sent i to me? Just edit the red parts in mynamespace?

  33. #33
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Add dll files to embedded resources

    Quote Originally Posted by fokeiro View Post
    So resolve.vb i just leave alone the way u sent i to me? Just edit the red parts in mynamespace?
    You need to work on setting up CustomerDllFileName and DllFolder to work for you.

    For instance, if you have a DLL named Support.DLL then CustomerDllFileName would reflect that and perhaps be renamed to SupportDllFileName

    With DllFolder I am sure the name I picked is for demoing only, I would think of a name that works for you instead of MyFolder which again is for demoing only.

  34. #34

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    should i leave resolve coding the way u sent it in post 24 or i have to edit it too ??

  35. #35
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Add dll files to embedded resources

    Quote Originally Posted by fokeiro View Post
    should i leave resolve coding the way u sent it in post 24 or i have to edit it too ??
    Only change it if something is not working, otherwise leave it be.

  36. #36

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    ok finally i manage for the dll not to appear where my form is but the embedded exe still showing , should i create another mynamespace ? Or is theee a way to write the exe to a tempfolder too then launch ?
    Last edited by fokeiro; Jul 4th, 2011 at 09:08 PM.

  37. #37

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    tried add another mynamespace and resolver and changing to exe but didnt work

  38. #38

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Add dll files to embedded resources

    How can i make a exe process in a button vut write the embedded resource to the same folder where the dll goes?

  39. #39

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Start embedded Exe from tempfolder

    or to a temp folder of any kind

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width