iam*_*mCR 10 .net vb.net dynamic envdte
我有一个解决方案和三个项目,它们都是动态创建的.现在我必须将第一个项目的引用添加到第二个和第三个项目.当我尝试逻辑时,我能够单独构建项目,并在构建解决方案时,它会抛出"Reference could not be loaded properly"错误..dll使用theVSProject.References.Add()方法直接添加时会发生这种情况.
所以我尝试使用以下代码作为上述问题的解决方案.但我仍然有一些错误.
Imports VSLangProj
' Add the second project as a reference to the first project.
Sub AddProjectExample()
' First project is a Visual Basic or C# project.
Dim theVSProject As VSProject = _
CType(DTE.Solution.Projects.Item(1).Object, VSProject)
' Second project is any type of project.
Dim secondProject As Project = DTE.Solution.Projects.Item(2)
' AddProject returns the newly created Reference object.
Dim newReference As Reference
newReference = theVSProject.References.AddProject(secondProject)
End Sub
Run Code Online (Sandbox Code Playgroud)
错误是,
The referenced assembly 'EnvDTE, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be found.
Run Code Online (Sandbox Code Playgroud)
对此有何解决方案?
我们没有VS IDE申请以下修复的文件夹的权限.
注意:还尝试了下面的解决方案App.Config但仍有问题.
NWard 绝对正确。不确定您尝试用于添加引用的代码,但可以以编程方式编辑项目根目录中的 csproj 文件,以在正确的位置添加以下内容:
<ItemGroup>
<ProjectReference Include="..\MyOtherProj\MyOtherProj.csproj">
<Project>{abda85bb-2019-4b80-982e-b90add3fcca0}</Project>
<Name>MyOtherProj</Name>
</ProjectReference>
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
调用内部调用的 powershell 脚本或某些控制台 exe。希望这可以帮助!