Cannot use external references with C# Console Application

落爺英雄遲暮 提交于 2019-12-04 02:49:50

Change the project Target to a non Client Profile target. Right click the Project and select Properties, you should see a list of Framework versions. As you are using VS2010, the Console project you've created by default targets .NET Framework 4.0 Client Profile, change that to .NET Framework 4.0.

Check if Copy Local is set to true for the referenced assembly.

First, as to your question, its hard to know exactly what you're doing wrong, but from the fact that you're using an underscore in an assembly name (and probably in namespaces and type names), it suggests you're rather new to the .NET world.

This suggests that you're adding references to other projects in your solution by browsing to the compiled assembly, rather than by adding a Project Reference. When adding a reference, you must select the Project tab rather than browsing for the assembly.

Even if you don't believe this is the issue, remove all references and re-add project references to make absolutely sure. Assumption, asses etc.

Once you've done that, I'd strongly suggest remove all the underscores from your types, namespaces and assemblies. You might want to go read the framework design guidelines, too.

Open your .Proj(Windows service project file) file in notepad and check whether your assembly location(data_object) is the same which you are pointing.

When you open .Proj file in notepad you can check for,

Project reference,

        <ProjectReference Include="C:\StackOverflow\StackOverflow.csproj">

And if you giving dll or exe refrence then

 <Reference Include="StackOverflow, Version=1.0.0.0, Culture=neutral,       processorArchitecture=x86">
  <SpecificVersion>False</SpecificVersion>
  <ExecutableExtension>.exe</ExecutableExtension>
  <HintPath>C:\StackOverflow\bin\Debug\StackOverflow.exe</HintPath>
</Reference>

I suggest you to give exact location including drive name like above example.

Other option you may try,

 1. Clean and rebuild
 2. Add Project reference if you already tried dll reference
 3. Check whether the folder (referred assembly location) is Read Only then remove it. 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!