Reputation: 4350
Just installed VS2017 and started by building a solution with two projects. A winforms project and a class library project.
Created objects and forms as usual and put a BindingSource in a UC but every time I try to select a class from que class library the Datasource propertie does not changes. Double checked the references and accessibility of the classes. I can add a any class from the WF project but none from the class library.
So I give a try using the Data Source window but it cannot see the class library project. Again I can add anything from WF project but looks like the class library compilation is invisible to or impossible to bind.
Already tried some answers from another questions and MSDN forums like changing the compile configurations from Any CPU to x86 or 64.
Upvotes: 3
Views: 1789
Reputation: 94
Today I've had this problem with VS2019 C#. I was trying to create some reports and I needed objects from other .net framework 4.8 library. I've tried to add object datasources and although I had no errors, no objects were added to the project.
After testing and checking for a while, the problem was the compile configurations. I have more than 100 projects in my solution and I had some for x64 and some for x32 (Any cpu). I've checked all of them and set the same compile configuration (any cpu with no 32 bit preferred in this case). Then, I've cleaned the solution (important!) and recompiled. Now I can add datasources without problem.
Upvotes: 1
Reputation: 4350
For the posterity: I found the problem.
When I created the Class Library project there are two options:
Happens .NET Standard is not compatible with .NET Framework (Winforms is .NET Framework) in some way one project cannot "read" the another dll and use their classes. Of course no one on VS/.Net bothered to raise an exception or make any kind of validation, they just let those thing happens unnoticed.
It just Microsoft being Microsoft and making itself incompatible.
I Created a new Class Library, this time .NET Framework and moved all classes to it and everything worked.
Upvotes: 1