'Can You Clone The CallingAssembly Object In .NET?

I'm trying to capture the Calling Assembly in an object and then pass it to a method that will then use it.

Here is what I'm trying to do:

'This code is called from another assembly
Dim objCallingAssembly As Object = Assembly.GetCallingAssembly()

'The executing assembly now passes the clone to a method in its assembly
PopulateCallingAssembly (objCallingAssembly)

Private Sub PopulateCallingAssembly(objCallingAssembly As Object)

    Dim strCallingAssemblyFileName = GetAssemblyFileName(objCallingAssembly.GetCallingAssembly().Location)
    Dim strCallingAssemblyName = objCallingAssembly.GetCallingAssembly().GetName().Name
    Dim strCAllingAssemblyVersion = objCallingAssembly.GetCallingAssembly().GetName().Version.ToString

End Sub

How can I make a clone (or copy) of the Calling Assembly object that will contain static values and not change?



Solution 1:[1]

Way to much complexity going on here. You just need

'This code is called from another assembly
Dim objCallingAssembly As Assembly = Assembly.GetCallingAssembly()

'The executing assembly now passes the clone to a method in its assembly
PopulateCallingAssembly (objCallingAssembly)

Private Sub PopulateCallingAssembly(objCallingAssembly As Assembly)

    Dim strCallingAssemblyFileName = objCallingAssembly.Location)
    Dim strCallingAssemblyName = objCallingAssembly.GetName().Name
    Dim strCAllingAssemblyVersion = objCallingAssembly.GetName().Version.ToString()

End Sub

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pm100