Home > Mobile >  Can You Clone The CallingAssembly Object In .NET?
Can You Clone The CallingAssembly Object In .NET?

Time:03-30

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?

CodePudding user response:

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
  • Related