none
Strong name failed when casting RRS feed

  • Question

  • Hi, I have simple example (extracted from more complex app, which is illustrating the need, not the purpose of the code)

    https://www.dropbox.com/s/p2z1kjs6tb9p3rt/test%20class%20casting.zip?dl=0

    The code fails when I cast in the 3rd file from IInter to impl.impl, but obviously it should not. Can you please fix or explain me what is wrong? 

    Cheers...

    p.

    Tuesday, March 31, 2020 3:16 PM

All replies

  • Hello,

    Rather than drop box show the relevant code and specify the line failing to cast. Then when you need at anytime to upload code using a .zip file use Microsoft OneDrive, setup an account with the same email address used here. 


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Tuesday, March 31, 2020 5:45 PM
    Moderator
  • when you had included the exception message in your post, we wouldn't have to download your code,
    adjust the hardcoded pathes (why do you do this?)
    and try to get it running.
    As the exception message explains: the types are in two different LoadContexts:
     cannot be cast to ...  in the context 'LoadNeither' ...in the context 'Default' 

    This has been asked before.
    "Cannot cast object of type 'x' to 'x'"
    (btw: The blog posts by Suzanne Cook have since been moved to Suzanne Cook's .NET CLR Notes)

    a better explanation is in:
    InvalidCastException when using Assembly.LoadFile

    And I hope you do not want to reinvent the wheel by writing your own plugin architecture.

    Tuesday, March 31, 2020 5:55 PM
  • Hi PavelPrague,
    I viewed a same case in this forum and it has been solved. So has your problem been solved?
    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 1, 2020 6:31 AM