“Are you missing an assembly reference?” compile e

2019-01-23 02:30发布

I am currently working on a server control for other applications in our company to interface with a WCF service. Every time I make a change code change and recompile the control, I increment the the AssemblyVerison and AssemblyFileVersion class in the AsseemblyInfo.cs by one. For example, my latest build went from 1.0.07.0 to 1.0.08.0.

When the consuming application updates the file by copying the latest file in the bin directory and tries to compile, they receive the following error:

The type or namespace name 'MyControl' does not exist in the namespace 'MyNamespace' (are you missing an assembly reference?)

In order to resolve this error, they have to delete the current reference and re-add the reference.

Is there any way to update the server control without having to delete and re-add the reference?

UPDATE:
I am not strong naming the server control.
@JPunyon - Do you mean have the consuming application add the server control project to their solution?

6条回答
看我几分像从前
2楼-- · 2019-01-23 02:59

Are you strong-naming your assemblies? In that case it is not a good idea to auto-increment your build number because with every new build number you will also have to update all your references.

查看更多
可以哭但决不认输i
3楼-- · 2019-01-23 03:00

In my case, I had to change the Copy Local setting to true (right-click assembly in solution explorer, select properties, locate and change value of Copy Local property). Once this setting was changed, publication of my WCF service copied the file to the server and the error went away.

查看更多
爷、活的狠高调
4楼-- · 2019-01-23 03:08

While creating new Blank UWP project in Visual Studio 2017 Community, this error came up.

enter image description here

After the suggested remedy (restoring NuGet cache) the reference resurfaced in the Project.

查看更多
做自己的国王
5楼-- · 2019-01-23 03:13

I bumped the answer that pointed me in the right direction, but...

For those who are using Visual C++:

If you need to turn off auto-increment of the version, you can change this value in the "AssemblyInfo.cpp" file (all CLR projects have one). Give it a real version number without the asterisk and it will work the way you want it to.

Just don't forget to implement your own version-control on your assembly!

查看更多
甜甜的少女心
6楼-- · 2019-01-23 03:19

Right-click the assembly reference in the solution explorer, properties, disable the "Specific Version" option.

查看更多
冷血范
7楼-- · 2019-01-23 03:24

In my case it was a project defined using Target Framework: ".NET Framework 4.0 Client Profile " that tried to reference dll projects defined using Target Framework: ".NET Framework 4.0".

Once I changed the project settings to use Target Framework: ".NET Framework 4.0" everything was built nicely.

Right Click the project->Properties->Application->Target Framework

查看更多
登录 后发表回答