I'm not that advanced with C# and need some assistance compiling a code. Honestly it's first time I'm doing that. I have a code that is aimed to automatically block rdp bruteforce.
Here is acode I'm trying to compile: https://pastebin.com/CJEapWyi
I've got problems interacting with firewall api.
In the internet people say I have to add reference to FirewallAPI.dll and I'm compiling code using following CLI:
c:\Windows\Microsoft.NET\Framework\v4.0.30319>csc.exe /r:"c:\windows\system32\FirewallApi.dll" c:\Users\Administrator\Documents\rdpbrute.cs
and it says:
error CS0006: Metadata file 'FirewallApi.dll' could not be found
Is there any way to compile a program that interacts with firewall using this compiler or I have to install visual studio?
Thanks for your time.
Instead of referencing c:\windows\system32\FirewallApi.dll you should first create COM interop library Interop.FirewallApi.dll and then add reference to it.
Interop library can be created with use of tlbimp.exe tool that is part of Visual Studio installation. A more simple approach is to use Add reference feature inside of VS (just select c:\windows\system32\FirewallApi.dll and interop library will be created automatically).
So you have to install VS as you suggested.
Related
My solution can be built properly, with no errors on my workstation while the same source gives an error when building with TFS.
The solution projects target .NET 4.0 and I use VisualStudio 2012 on the workstation.
Using tfs.visualstudio.com (tfspreview.com) to keep the source, which I tried building with the Hosted Build Controller on tfspreview and with my own Build Controller that I host with TFS 2012 on my server.
I get the error in code where I use dynamic ExpandoObject.
Why my solution can't build on TFS?
I can provide more details if needed.
Have you tried the hosted build to see if that works?
Is is definitely the expandoobject? if you comment out that code does the build succeed?
can you send an excerpt from the build log?
I will post this as an answer as it solved this strange problem.
One of the project's solutions had two separate references to same open source library. One to the downloaded precompiled library, and one to another project where I kept the source of the same library. The first one was added by Nuget, the second manually.
The possibility to actually do this (add two references of same assembly) was probably a bug in Visual Studio or Nuget. Later when I tried to reconstruct this bug, an error message appeared, saying there is already reference to the specific assembly name.
For the compiling, I understand that TFS build agent considered only the precompiled assembly (Nuget package) and threw an error.
Visual Studio considered the assembly source which I modified to use with ExpandoObject.
Calling build command manually produced the same error as TFS did.
I removed both references and added only one (the other couldn't be added again anyway). That equalized the build behavior of TFS and VS for my solution.
I know this is very odd and I still can not remember how that double reference bug occurred in the first place. My guess is, this error can be reconstructed by editing the .proj file manually.
I have been trying to monitor video memory for a highly performance intensive program.
So I used the NVIDIA CUDA libraries in a C++ Visual Studio Application to collect the data I need.
Unfortunately I need a package that can be used with Ruby, C# and the Software Testing tools my company has.
So I decided to compile a C++ DLL and import it into a C# Visual Studio Project for testing.
I was able to compile the DLL but importing it into my Visual C# Program has been an issue.
I right Click on References -> Add Reference. Then I click on the Browse tab and browse to the location of my DLL; "TestProgram.dll" and I click "OK"
Then I get the following Error message "A reference to C:.... could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component."
What I have tried so far:
1. Importing the DLL from several different locations on my system.
2. Moving the DLL into my Solution Explorer and importing it
3. Using the "Invoke" method: [DllImport("PathToMyDll")]
4. Using the "Invoke" method with just my dll name.
5. Typing 'using' path to my DLL
6. Exporting the dll as a .lib file instead
What am I doing wrong? I thought that if I exported a DLL using Visual Studio 2010 then surely that same DLL could be Added into a Visual Studio 2010 project.
Well, is it a valid Assembly or COM component? Just because it's a C++ DLL doesn't mean it can be used with just a reference, in fact, most can't. It needs to be a managed DLL or a COM object. If it's none of those, then you have to invoke unmanaged code from a managed assembly. That means defining each function in a stub.
More info here: how to call a C++ dll exported function from c#
Be aware, you also have to deal with 64/32 bit issues, since if the DLL is compiled for 32 bit, you can't use it in a 64 bit application.
I found the solution to this problem. CUDA creates a Windows Console Application project. So the solution was to just use that instead of a DLL.
This worked well because Ruby, Test Complete and Visual C# can read the output from a basic .exe console program (with some work).
The compiled exe is simple. All I need to do is pass in an integer as an argument when I launch the program and the program will get the data I need from my NVIDIA card.
The challenge now will be finding a good way to interface with the .exe.
This is for C#.
I know that I can include a COM File as a resource in my executable and then unpack it into the current directory when its needed. A com file such as LibCurlNet.
What I would like to know is if Visual C# 2010 Express provides an automated way of doing this.
Such as a simple option that I can select. I do not mean using the publisher.
I don't even think there is an automated way in Visual Studio Professional/Ultimate for doing this, let alone VS Express. You probably need to use a more manual approach, such as the one described here (but I guess you already knew that).
There is a tool for packing .NET DLL:s and native DLL:s called NETZ. Granted, I have not tried it myself, but maybe this tool can be of some help to you?
everyone, I am having a question or problem when building a setup project for an add-in (both are developed in c#). The add-in is used for a big software, and it needs a DLL from the software. If I just build the add-in and use it, it is fine. But if I install it using a setup project, the DLL provided by the software should also be copied to make the add-in work. But since if the client who uses the software, has already the DLL (coming along with the software), so I wanted to skip this DLL, so exclude it from the setup. But if I do so, I will get error 1001 when installing the add-in, saying at least one type from the assembly (the add-in) cannot be loaded. If I include everything (all the dependencies), it works.
So does anyone have idea about this? How can I skip the already available DLL that comes along with the software?
you can use web deployment project to build your application instead of the default publish in visual studio and before building it right click on the WDP and select Open Project File:
inside the .wdproj file search for item group <ItemGroup></ItemGroup> tag and add the following
<ExcludeFromBuild Include=”$(SourceWebPhysicalPath)\FolderName\**\*.*” />
I'm toying with my first remoting project and I need to create a RemotableType DLL. I know I can compile it by hand with csc, but I wonder if there are some facilities in place on Visual Studio to handle the Remoting case, or, more specificly, to tell it that a specific file should be compiled as a .dll without having to add another project to a solution exclusively to compile a class or two into DLLs.
NOTE: I know I should toy with my first WCF project, but this has to run on 2.0.
You can get away with just calling csc.exe on the pre-build event if you don't want to mess with the .proj file directly and add build events.
None that I know of using VS 2008 at the moment.
But you might want to check out NAnt. It is made for this kind of work.