Missing lib.exe while compiling Notepad++ dll in C# - c#

I want to compile a plugin for Notepad++ and used a .NET plugin to be able to write it in C# (VS17).
Without adding any code myself, the warning "Cannot find lib.exe in [...]\VC\bin" pops up.
I do get the .dll file but Npp throws two errors when adding the plugin to it:
Wrong version of Plugin
ANSI/Unicode Error
I am pretty sure that at least the version is correct, as I tried it with multiple Npp-versions, so i figured that maybe it's all about that warning.
Any suggestions?

"lib.exe" is part of the C/C++ toolset and is installed when support for the C/C++ language is selected in Visual Studio. Modify your Visual Studio to include C/C++ support. Running the set up program should allow the wanted suport to be selected and installed.

Related

How to get intellisense in Visual Studio Code for Unity functions names?

I am following a tutorial about Unity and I see that the instructor has intellisense when writes the method's name.
However I have only intellisense with classes and variables, I mean Unity classes like Rigidbody and my own variables.
I have also read:
Autocompletion not working in Visual studio
How to enable intellisense in Visual Studio 2017 for Unity
Old question, but I had the same problem just recently.
There must have been an issue in your Assembly-CSharp.csproj or project-name.sln files. Most likely to be the .csproj file. If you take a look at it, you will see various references to .dll files.
You can tell Unity (my version: v2019.2.20f1) to create these for you by enabling Edit > Preferences > Generate all .csproj files.
1. Delete both files.
2. Enable .csproj file generation.
3. Double click on a script in Unity.
This fixed my issue.
I would really like to clear things up a bit for everyone trying to get Intellisense working with Visual Studio Code.
First of all I am writing this for Unity 2019.4.14 (edit: also for 2020.3 and 2021.3).
These are the things you MUST do for this to work:
You need Visual Studio Code (duh)
You need .NET SDK. I don't think it matters which version, latest is the best I guess. Make sure you install the SDK, not the runtime.
Check if you have .NET SDK installed by typing dotnet in the VSCode terminal.
You also need The .NET Framework Dev Pack because otherwise VSCode is going to be throwing this error:
The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application.
In VSCode search for the 'C# for Visual Studio Code' extension and install it
In Unity go to Package Manager and install Visual Studio Code Editor. This will enable Unity to generate proper project files for VSCode. (might be already installed)
In Unity go to Edit -> Preferences -> External Tools and choose VSCode from the dropdown (could be listed as code.cmd) and after you choose it tick all the checkboxes you want in the Generate .csproj files for section. I checked Embedded Packages, Local Packages, and Packages from unknown sources. Click 'Regenerate project files'
Open any C# file from Unity and you should be good to go. (you might need to restart VSCode after regenerating project files in order for this to work)
Now, what about Unity Code Snippets and Debugger for Unity extensions? Well these are useful helper extensions but they have nothing to do with Intellisense. The first is for quickly typing common Unity patterns and the second is for showing Unity Debug warnings and errors as you type instead of saving and going back to Unity and reading the console.
Hope this was of any help.
p.s.
One more note: Visual Studio Code depends on the solution files we generate through Unity for Intellisense to work. This is important because you have to add the entire project folder to VSCode workspace and not just Assets folder or your Scripts folders. If you add only the Assets folder to VSCode it won't be aware of those solution (.sln) files. If you open scripts through Unity it will probably work regardless.
Although the answer by Alex Myers is helps, its not 100% right. Unity Snippets does give you some snippets, and the illusion of typeahead, it's not actually intellisense.
For true intellisense you need to:
install dotnet on your system (https://code.visualstudio.com/docs/languages/dotnet) and,
install the dotnet extension for VSCode (https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp)
More information can be found here: https://code.visualstudio.com/docs/languages/dotnet
You can test you have dotnet installed by typing dotnet into the terminal within VSCode.
Note In the image below how I get a full method signature, reference counts, and the yellow hint globe. These are only available when using dotnet + extension (and not available when using the snippets)
Note: my solution does not solve intellisense to function names, but this was the first question that come in fixing intellisense more generally in VSCode.
I needed to update the VSCode package in unity.
In Unity, click Window, then Package Manager, then look for Visual Studio Code Editor. Expand it by pressing triangle, and upgrade to the latest version (for me, it was 1.2.0. I restarted VSCode and it worked.
v1.1.4 had a bug that caused this problem, and was not fixed for about 3 months. It is still the default package installed with a new default project, so you have to change this package version to 1.2.0 in every new project, until they update it.
Check out the guide for Unity Development with VS Code. They recommend a few extensions:
Unity Snippets
Debugger for Unity
Unity Tools
I believe the Unity Snippets extension is what you are looking for.
For anyone having the same problem on a Mac, try setting this value in your .vscode/settings.json (or in the user settings instead of the workspace settings)
"omnisharp.useGlobalMono": "always"
For me just in Unity, Edit/Preferences/External Script Editor, and changed it to My_Install_Location\Microsoft VS Code\Code.exe (maybe hit Regenerate Project Files)
Sorry, I don't have good English, but I'll show you what worked for me.
I opened the C # script in Visual Studio Code and looked for the Assembly-CSharp.csproj file, then, on line 16, I changed the following:
<TargetFrameworkVersion> v4.5 </TargetFrameworkVersion>
For:
<TargetFrameworkVersion> v4.5.1 </TargetFrameworkVersion>
This solved the Intellisense issue.
Intellisense is a pure workflow of .Net Environment. So, you need to have .Net 'Developer pack' (not Runtime) installed on your system as it installs all three necessary components below:
.Net framework
.Net Target pack
.net SDK
reference link: https://dotnet.microsoft.com/download/visual-studio-sdks
It is directly installed to a system admin-accessible path, so no need setting it up. Now, you have to tell VS Code which .Net version to use (whichever you have installed).
Your Unity project will have these two files in the root directory:
Assembly-CSharp.csproj
Assembly-CSharp-Editor.csproj
In these both files search for line (probably 16):
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
Edit version that you had just installed (I had 4.8). Then reopen VS Code. Now everything should work fine.
I found another solution since none of the other solutions were working for me and i was searching for hours.(07/08/2021):
I got the feeling i found the solution for a lot of people since i reinstalled windows recently and simply downloaded everything needed to start without other problems.
I got the same error with .NET, .NET Core or .NET Framework, here are some screenshots of the errors:
In the error output, it says to install the Developer Pack for this framework version. You can find the version in the .csproj file:
By installing the .NET Framework of this version on the dotnet microsoft site: .NET Framework download list
i fixed the error after reloading VSCode and got my Intellisense working for Unity.
TLDR:
My fix was too install .NET Framework version 4.7.1
If you still can't enable IntelliSense, make sure you have VS Code opened in the same directory as the .sln file (I had mine opened deeper in the Assets before).
Source:
https://code.visualstudio.com/docs/other/unity
Though the question is 2 years old, the problem pops up occasionally, just like happened to me.
I had the issue myself, so this one is possibly the first that should be checked.
"Install .NET Framework 4.6 Targeting Pack"
WHY?
First of all, I work with dotnet core, not the standard, so I don't have standard libraries installed on my computer. When I started trying Unity, and VS Code with it, this was the missing part I wasn't aware of.
When I hit the issue, I searched the net a while and see this question. Took me another while to notice this framework sentence in "Enabling code completion" section of VS Code and Unity page. So I tried and now I am happy I tried.
Just don't forget you need to restart at least VS Code to get the intellisense working.
PS: Framework version may, and will most possibly, be changed depending on what year we are in, and which versions we use. So if "4.6" is not working then you probably need another version.
PS2: If it is Mac you are looking for, follow the same link above and find the same section I mentioned above to get a link for .NET SDK.
Follow these steps:
Go into your Unity project.
Go to Edit.
Go to Projects preferences.
Go to External tools.
In line "External Script Editor" you have to change to "Visual Studio Cummunity 2019..."
then it should work.

Visual Studio C++/CLI Mysterious Error With Template

Well, I've been trying to make a C++ DLL in Visual Studio 2015, which took a while since I'm not very good with Visual Studio.
I need to access the .NET libraries, specifically System::Management. (Writing the code was a little harder than it needed to be due to a poor C++ implementation, but at least it has one.)
I fixed obvious errors and finally figured out I had to enable CLR in the project properties and then select the related libraries with References->Add Reference. But after all that, now it's just giving this weird error:
LNK1104: cannot open file 'MSCOREE.lib'
The compiler doesn't show red wavy lines below anything, and the error claims the line is "1" and the file is "LINK", so no help there.
I thought I probably messed up the project configuration somewhere, so I created a new project and moved the code over. The error still happened. If I turned off CLR and commented out the .NET-dependent code, the build succeeded without errors.
So I tried creating a new project from template (Visual C++ -> Win32 Console Application) and then enabling CLR before doing anything else. Then I tried again, selecting different versions of .NET framework.
Finally, I tried creating a project with template (Visual C++ -> CLR -> CLR Console Application) and building it immediately. I mean literally without doing ANYTHING ELSE. It still gave the same error!
LNK1104: cannot open file 'MSCOREE.lib'
What on earth is going on? Am I doing something wrong here, or is VS2015 just broken?
I had the same problem. Installing ".NET Framework 4.6.1 SDK" solved the problem. Pay attention to the version number, take it from your project configuration files
Check in Visual Studio installer 'C++/CLI support' for build tools of your needed version.
Try this,
Right click the project that shows 'LNK1104: cannot open file 'MSCOREE.lib'', then select Properties --> Configuration Properties --> VC++ Directories --> Library Directories --> Add both entries from below separated by semi-colon
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64
This is where your 'mscoree.lib' should be, check if its there before doing this otherwise you might need to install/reinstall the Microsoft SDKs
In some situations the SDK may not install the required files in the LIB folder as described in MSCoree.lib missing from WinSDK. Their solution was to execute a repair of the install. That may not work.
I have successfully ran WinSDKInterop_amd64\WinSDKInterop_amd64.msi resulting in the creation of:
C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\IA64\mscoree.lib
C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\mscoree.lib
C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64\mscoree.lib

VS2015 Illegal tables in compressed metadata stream

We're experimenting with upgrading from Visual Studio 2012 to 2015. The only error we ran into was
xyzRenamed.dll could not be opened -- Illegal tables in compressed
metadata stream.
We've been using this customer-supplied api dll in 2012 for a couple years without any trouble. Does anyone have any idea why 2015 would be unhappy with the dll while 2012 worked fine? Any way to avoid it?
It is likely that one of your DLL is obfuscated, specifically by a FOSS project called Confuser Ex. That project can be used in Visual Studio (as an addon) to obfuscate your code. When using that tool, you have a choice of protection layers. You can use some or all the layers. The protection that creates invalid metadata in the compiled DLL is the one that is creating this odd error.
You can deactivate the invalid metadata protection when generating the obfuscated dll in VS settings at VisualStudio->Tools->Settings->ConfuserEx.
In case you did not create the library, you need to investigate further, maybe use something else than Visual Studio 2015 to compile the project.
Remove
<protection id="invalid metadata" />
line from CRPROJ file.
It turned out that the customer had obfuscated their DLL by an invalid metadata tactic. Specifically, they were using ConfuserEx. This seems to work fine with VS2012, but VS2015 wasn't having it. Here is a bug report at ConfuserEx regarding the issue and it was basically deemed as expected behavior. https://github.com/yck1509/ConfuserEx/issues/313
We were able to get them to rebuild the DLL without this type of obfuscation and it worked fine.
I'm currently unaware of any way we could have modified our VS solution to make use of the obfuscated file. If you know of a way then please post it for others that aren't lucky enough to be able to acquire a non-obfuscated version of their dependency.

Having problems editing a dll in visual studio

I have a file called Asembly-CSharp.dll i want to edit in C#. I decompile it with .NET reflector's FileGenerator (also tried file disassembler and dotPeek) plugin, thus creating a visual studio project, i open it in visual studio, but it fails to build, i didn't change anything, yet i get lots of errors (like unexpected characters etc), the dll refers to lots of other dlls but even if i put all of them in one solution it fails. Why does it fail if i didn't change anything in the source code (.NET framewrok version is the same as it was before decompilation). Any help appreciated.
I tried both visual studio 2012 and 2013 (win7 but i know that shouldn't be the problem)
I'm not professional, forgive me if i made some silly mistake.
Reverse engineering needs a bit of effort. Nothing comes for free. You need to manually fix those errors.
Mostly these errors occur because either Reflector decompiles the code with compiler-generated variable names that are valid in IL but not in C#, or because that particular assembly was written in some other language that supports features that cannot be directly translated to C#.

Add FreeImage .NET to solution

I have followed the posts on this, but i am still not getting a few steps. I am new to C#, and that is probably the issue. I would love a little help (I have been banging on this all day).
I can open the FreeImage.NET solution (Win7 64 bit machine btw) in Visual Studio. This post says i need to Build it to get the C# dll. When i build it, i get hundreds of errors "type or namespace 'Name' could not be found".
Does it need the C++ DDL added first? I dragged and dropped it onto the solution, but still the errors.
Am i doing something simple and wrong?
Specifically what i am trying to do is add FreeImage to project in C# Visual Studio Express 2012.
Thanks,
Dan
After downloading the version of FreeImage.NET , I opened the following VS2005 Solution File in VS2012.(Thats the only one I have)
FreeImage3154\FreeImage\Wrapper\FreeImage.NET\cs\FreeImage.NET.2005.sln
After upgrading the project and building it for the first time, I saw around 491 errors. If you open the references of the UnitTest.2005 project, you will see that the nunit.framework assembly is missing. If you have nuget installed , in VS2012 you can
Right Click references > Manage NuGet Packages > Search for NUnit and install it.
In the image below we see that the nunit.framework assembly is correctly linked.
After doing this there were only 50 errors remaining and they were all because the Xml Documentation file checks were enabled. You can disable this check as shown below in the Library.2005 project.
Build again, and it should succeed.
NOTE: The FreeImage website provides only a 32-bit version of the DLL, thus to use this DLL you will have to ensure that you set your project version to 32-bit. To obtain a 64-bit version of the FreeImage DLL you will have o download their source code project and manually do a 64-bit build as show in this blog.

Categories

Resources