简体   繁体   English

数据访问项目dll未添加到客户端bin文件夹中

[英]Data Access project dll is not being added to the client bin folder

Hi I am creating new project in visual studio using the following structure: 嗨,我正在使用以下结构在Visual Studio中创建新项目:

在此处输入图片说明

Now the way things will be referenced will be using the following structure: 现在,将使用以下结构来引用事物:

  • Client projects will only reference Commercify.Product.Contracts 客户项目将仅引用Commercify.Product.Contracts
  • Commercify.Products will reference Commercify.Product.Contracts and Commercify.DataAccess.Contracts Commercify.Products将引用Commercify.Product.Contracts和Commercify.DataAccess.Contracts
  • Commercify.DataAccess references Commercify.DataAccess.Contracts Commercify.DataAccess引用Commercify.DataAccess.Contracts
  • Infrastructure.Injector will be referenced only in client and will be used for registering dependencies Infrastructure.Injector将仅在客户端中引用,并将用于注册依赖项

In startup I am calling the following code: 在启动时,我正在调用以下代码:

       Assembly assembly = Assembly.Load(new AssemblyName("Commercify.DataAccess"));

When this code gets executed I get the following exception: 当执行此代码时,出现以下异常:

{"Could not load file or assembly 'Commercify.DataAccess, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.":"Commercify.DataAccess, Culture=neutral, PublicKeyToken=null"}

Now I am assuming that this is happening because Visual Studio does not seem to see that Commercify.DataAccess is actualy needed because its not referenced anywhere in the other projects. 现在,我假设发生这种情况是因为Visual Studio似乎没有看到Commercify.DataAccess确实是必需的,因为在其他项目的任何地方都没有引用它。 I had the exact same problem problem in a project that used csproj type of projects so it is not a dxsproj problem. 我在使用csproj类型的项目的项目中遇到了完全相同的问题,因此它不是dxsproj问题。 I had solved it by using a post build event. 我已经通过使用post build事件解决了它。

I would prefer to have a more clean solution to this if there is one. 如果有的话,我希望有一个更干净的解决方案。

Can anyone tell me how to solve the problem? 谁能告诉我如何解决这个问题?

You are loading dynamically a DLL, so Visual Studio doesn't has a clue that it needs to be copied. 您正在动态加载DLL,因此Visual Studio没有提示需要复制它。

Or you stick with the post-build events (I am working in an exact case like that and that's the best approach) or you add a reference to the project on the other projects, but it defeats the purpose of loading dynamically an assembly. 或者您坚持执行构建后事件(我正在这样的情况下工作,那是最好的方法),或者在其他项目上添加了对该项目的引用,但是这样做破坏了动态加载程序集的目的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何访问ASP.NET MVC项目的bin文件夹中的DLL? - How to access DLL in bin folder of ASP.NET MVC project? 无法将文件“ C:\\ Data.dll”复制到“ bin \\ Data.dll”。 该进程无法访问文件“ bin \\ Data.dll”,因为它正在被另一个进程使用 - Unable to copy file “C:\Data.dll” to “bin\Data.dll”. The process cannot access the file 'bin\Data.dll' because it is being used by another process 如何从dll项目内的bin文件夹中获取文件夹位置? - How to get a folder location from the bin folder inside a dll project? 添加文件夹到类库项目,引用DLL时无法访问命名空间 - Added folder to class library project, cant access the namespace when referencing DLL 自动将本机dll复制到Visual Studio中引用项目的bin文件夹中 - Automaticaly copy native dll to the bin folder of referencing project in Visual Studio 为什么将dll从GAC复制到project \\ bin文件夹 - Why a dll is copied from GAC to project\bin folder 将dll存储在与bin不在同一项目中的另一个文件夹中 - store dll in another folder not in same project other than bin 尽管出现错误“无法加载DLL'SQLite.Interop.dll'”,尽管它位于bin文件夹中 - Getting error “Unable to load DLL 'SQLite.Interop.dll'” despite it being in the bin folder 发布dll - 复制到bin文件夹 - Publish dll - copy to bin folder 将DLL添加到SharePoint bin文件夹 - Add DLL to SharePoint bin folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM