none
My project builds successfully and runs well. but.... RRS feed

  • Question

  • It consists of two projects in one solution.

    One outputs as a dll and one outputs to an exefile.

    My project builds successfully and runs well.

    But I get error CS0103 in the error list.

    My Visual Studio Version is 2019. The latest version.

    And....

    I don't know the cause, but I found a solution.

    In Solution Explorer-> References-> "Referenced Projects"(project name output as dll)-> Right-click-> Properties-> Embed Interop Types,

    change the value to False-> true-> false.

    Why? Is it VSbug?

    I guess it is related to the .vs folder. Because

    Doing the following will not generate an error :
    1. Change the Value Interop type to False-> true-> False.
    2. Copy the .vs folder to another location.
    3. Delete the .vs, bin and obj folders, then overwrite the previously copied .vs folder in the solution folder.





    Monday, September 23, 2019 9:23 AM

All replies

  • Hi developmentdevil,

    Welcome to the MSDN forum.

    For your question I can tell you that this is not a bug. The error CS0103 means that you have indicated that you are using locally defined parameters globally. You can check this document for error CS0103. So I suspect you made the mistake in the library.

    > >Embed Inteop Types simply embeds the managed bridge code used. This code lets you communicate with an unmanaged assembly, but instead of embedding it all, just create what you actually use in your code.

    When you change change Embed Inteop Types to true, the interoperability type information is provided by the primary interoperability assembly (PIA) and it will ignore the error so that you can build your project successfully.

    But this approach is a solution but not recommended, especially for large projects. So I suggest you still double check that the parameters in your class library code are best defined in the global.

    So the problem is simply the difference between VS setting up the library differently.

    More information you can refer to this document:

    https://stackoverflow.com/questions/20514240/whats-the-difference-setting-embed-interop-types-true-and-false-in-visual-studi

    > >.VS folder stores some configuration information in your project including Embed Interop Types. Vs automatically reads the configuration in the file whenever you open the project.

    Hope it could help you.

    Best Regards,

    Perry


    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


    Tuesday, September 24, 2019 7:41 AM
  • Hi developmentdvil,

    Did your issue solve? Did you understand  the use of Embed Inteop Types? To be more rigorous, you need to re-examine your library to find the parameters declared locally and move them to the global level. 

    If my reply is helpful for you to solve your issue, please remember to mark is as answer. If your issue still persists, please feel free to let us know. We are willing to help you further.

    Thanks for your understanding.

    Best Regards,

    Perry


    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

    Monday, September 30, 2019 9:23 AM