简体   繁体   English

Visual Studio 2019,C# 代码库,是否可以更改引用的名称?

[英]Visual Studio 2019, C# codebase, Is it possible to change the name of a reference?

I've got an odd concern here.我在这里有一个奇怪的问题。 I think I may need to change the name of a reference in my VS project, although I'm not sure this is even possible.我想我可能需要更改 VS 项目中引用的名称,尽管我不确定这是否可行。

I have a VS project that was provided to me by an industrial camera manufacturer.我有一个工业相机制造商提供给我的 VS 项目。 In their project, which runs as expected, they have a reference named "ArenaNET".在他们按预期运行的项目中,他们有一个名为“ArenaNET”的引用。 The actual name of that file is ArenaNETd_v140.dll yet somehow their project loads it in as "ArenaNET", as I said above.该文件的实际名称是 ArenaNETd_v140.dll,但正如我上面所说,他们的项目以某种方式将其加载为“ArenaNET”。

In my project, which is attempting to run their exact same code, I've added a reference to the same file, ArenaNETd_v140.dll, and my project loads it in as "ArenaNETd_v140".在我试图运行完全相同代码的项目中,我添加了对同一文件 ArenaNETd_v140.dll 的引用,并且我的项目将其加载为“ArenaNETd_v140”。 My project, when I run it, complains:我的项目,当我运行它时,抱怨:

System.BadImageFormatException: 'Could not load file or assembly 'ArenaNETd_v140, Version=1.0.7347.17842, Culture=neutral, PublicKeyToken=null' or one of its dependencies. System.BadImageFormatException: '无法加载文件或程序集'ArenaNETd_v140,版本=1.0.7347.17842,Culture=neutral,PublicKeyToken=null'或其依赖项之一。 An attempt was made to load a program with an incorrect format.'试图加载格式不正确的程序。

It's likely that I'm missing something here, maybe using the reference wrong, but it strikes me as odd that between my project and the project provided to me, the only difference appears to be in the name of the reference.很可能我在这里遗漏了一些东西,可能是使用了错误的参考,但让我感到奇怪的是,在我的项目和提供给我的项目之间,唯一的区别似乎在于参考的名称。 So with that, I'd like to ask 2 questions:因此,我想问两个问题:

  1. Does the name of the reference in a C# Framework Project matter? C# 框架项目中引用的名称是否重要?
  2. Can the name of the reference be changed, within Visual Studio?在 Visual Studio 中可以更改引用的名称吗? (2019 or earlier) (2019 或更早)

EDITS:编辑:

Looking more at the VS project provided to me, it looks like their project has a build dependancy on another project in their folder, named ArenaNET.更多地查看提供给我的 VS 项目,看起来他们的项目对其文件夹中名为 ArenaNET 的另一个项目具有构建依赖性。 This must be where that name is coming from.这一定是这个名字的来源。 It appears the difference between my project and theirs (so far) is that they directly reference the ArenaNET project while I am attempting to reference the dll created by their ArenaNET project.看起来我的项目和他们的项目(到目前为止)之间的区别在于他们直接引用 ArenaNET 项目,而我试图引用由他们的 ArenaNET 项目创建的 dll。

Ultimately, I was able to solve my problem.最终,我能够解决我的问题。 David Browne's comment about checking the "bitness" lead me on the right path. David Browne 关于检查“位”的评论使我走上了正确的道路。 I'll try to summarize what I learned.我会尽量总结我所学到的。

Does the name of the reference in a C# Framework Project matter? C# 框架项目中引用的名称是否重要?

I have no idea if it matters, but I don't think it does.我不知道这是否重要,但我认为不重要。 The name likely isn't the true issue;这个名字可能不是真正的问题; for me, I had to carefully ensure I had the right "bitness" for the dlls I was building.对我来说,我必须仔细确保我正在构建的 dll 具有正确的“位数”。

"bitness"??? “比特”???

In case you're confused on this, the "bitness" refers to the platform.如果您对此感到困惑,“位数”是指平台。 Ie I've got a windows 64 bit machine, so I needed to be building my Visual Studio dlls for the x86 platform.即我有一台 windows 64 位机器,所以我需要为 x86 平台构建我的 Visual Studio dll。 Building the VS dlls for Win32 or x64 did not solve my problem.为 Win32 或 x64 构建 VS dll 并没有解决我的问题。

Important Note: If you are building the dlls so you can put them somewhere else, be sure you are grabbing the dlls from the correct folder!!重要提示:如果您正在构建 dll 以便将它们放在其他地方,请确保您从正确的文件夹中获取 dll!

Can the name of the reference be changed, within Visual Studio?在 Visual Studio 中可以更改引用的名称吗? (2019 or earlier) (2019 或更早)

I have no idea.我不知道。 If the name truly doesn't matter, then I imagine the reference name cannot be changed.如果名称真的无关紧要,那么我想无法更改参考名称。 Again, the name of the reference likely isn't the real issue.同样,引用的名称可能不是真正的问题。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM