I'm going to ask a newbie question here. I need to use a control I found online in my code, but it was written in the wrong language. It is in C# and I am using VB.net for work. I have all of the code for the control which works beautifully in C#, but I had issues with it not working very well in VB.
The source code and a demo project are available here, but I am not sure exactly which files I should use to build the dll for VB.
It seems a lot to ask, but would someone mind taking a look and pointing me in the right direction?
Cheers
Add the project to your solution, or just build it using your version of Visual Studio. Then add a reference, either to the project in the first case, or the .dll in the second.
If the Control doesn't work well, it's not because it's written in C# as opposed to VB.Net.
You should be able to use/reference the DLL as-is from your visual basic solution. It doesn't matter whether it was written in C#, VB.NET or any other .net language.
One you compile a dll from the c# source it will work exactly the same as if it were written in vb. You simply need to create a reference to the dll in visual studio.
Related
This question already has an answer here:
Is there a way to see decompiled C# code in VS Code?
(1 answer)
Closed 5 months ago.
Prerequisites:
I use Visual Studio Code Version: 1.63.2 (Universal)
MacOS Monterey 12.03 with M1
.NET version 6.0.302
Originally I am coming from Python, but lately, I interact with C#(in particular ASP.NET Core 6) a lot.
I have been trying to find an answer to a question:
How can I go to the implementation of the method/class in a dependency package installed in my .NET project? Is it possible to do it in VSCode?
Probably, I am just struggling with how should I formulate this question, so let me provide some examples below.
If I am using PyCharm and, let's say, have an installed package flask-login. I can import the function login_user as on the screenshot below.
Then just go to its implementation and see the whole code as on the screenshot below.
This happens because both in PyCharm and in VSCode it redirects me to the files stored in the bin directory of my interpreter path. As a result, I can always go locally and check the source code of all installed dependencies.
Now coming back to C#: I want to have the same thing in my .NET project with VSCode (I don't use Visual Studio and use MacOS). As for now in VSCode, I can only go to the interface code of a dependency and when I press go to implementation it says Implementation not found.
I am not sure whether this is possible or not, since C# is a compiled language, so probably it would require a decompiler for this to work. The only thing I managed to make work was the possibility to jump into implementation during debugging session https://github.com/OmniSharp/omnisharp-vscode/wiki/Debugging-into-the-.NET-Framework-itself. At the same time, this is slightly different from what I want -> I just want a convenient way to go into the implementation source code to understand what is happening in the code LOCALLY and probably set breakpoints in this code if I think it makes sense.
Therefore, my main question stays the same: Can I do it on MacOS in VSCode?
UPD: I tried Rider from JetBrains(https://www.jetbrains.com/rider) and it works there. Still interested in making this work in VSCode.
An answer is basically here -> Is there a way to see decompiled C# code in VS Code?
There is a feature to enable decompilation in omnisharp extension for C# in VSCode.
Thanks to #UnholySheep!
I want to create a Windows application using a C# GUI that calls some C++ code but I have troubles setting up the project in Visual Studio.
I understood that I have to do it the following way : 3 projects (the C++ project, the C# project and a wrapper CLR project) that are linked to each others in some way. I just can't figure out how the link works.
If anyone can explain me in details what I have to do, I'd be really happy :3
Otherwise, I can use a Github link of a project already set up that I could copy.
Thanks in advance to anyone who will take some time to answer.
I am trying to build a C# project (downloaded code) in Visual Studio Express 2008. I get the error (my translation):
The type or namespace name "Allegro"
couldn't be found.
for the line
using Allegro;
I know the 2D graphics library Allegro, of course, but I can't find much information on how to use it in C#. It is being used for visualization in the project I am trying to compile.
I also get the warning
This reference couldn't be resolved.
The Universal assembly couldn't be
found.
I haven't been working with C# before and and I barely know Visual Studio Express. These are newbie mistakes - but I just need a fast solution for this problem. Could someone provide me with a short step-by-step solution?
Remove old reference of Allegro.dll from project and add it again.
Allegro isn't a .NET library; it's written in traditional unmanaged C. If you downloaded code that references an Allegro C# library, then perhaps the author was using some unofficial C# bindings. If so, the solution is to find that additional library and use it.
Otherwise, there is no short, step-by-step solution. You would need to use DllImport on each function that you need, and follow the standard practices for using unmanaged C DLLs in C#.
I am supposed to be updating a piece of software for someone. Originally written in VB 6 I want to import it into a .net c# project. My question is, I don't want to have to lay out all the forms again and I am wondering if, or how, I could import them into c# project. They originally come with the .frm extension and c# forms are .cs. I tried 'add existing item' to the project but obviously that didn't work, and I tried a couple of other things. Is there a way of importing them that would work? I just need the layout, not worried about the underlying code or anything as this will all be re-written.
Thanks, R.
You can utilize the VB upgrade wizard, but that will only get you to VB.NET (potentially as there as some things that cannot be upgraded). Or you can compile your VB6 app to a COM dll... then call the COM dll via interop.
As already mentioned, you can migrate to VB.NET first. You can copy and paste controls from one project's form to another's.
How can I convert my C# code to DLL file in a way that the user of DLL can’t view my source code?
When I make DLL in the way I always do by making a class library project, importing my classes and compiling it, the source code can still be viewed.
I believe you are looking for an obfuscator. This is a tool that will take a compiled DLL and rewrite the code with the intent of it not being meaningfully decompiled by another user. Visual Studio comes with a free Dotfuscator
Note, this will not actually prevent people from looking at your code. They will instead be looking at a very weird translation of your code. There is no way to prevent people from looking at decompiled versions of your code in C# or any other .Net language for that matter.
This is not something that is unique to C#. It is fact a flaw of every language in existence. It's perfectly possible to decompile C code. The difference though is it's much easier to maintain a lot of the original code structure when decompiling managed languages (.Net and Java for instance) because the metadata maintains the original structure.
obfuscation is what you want to search for.
There is a free one (that is limited) in visual studio called Dotfuscator.
Uses fancy methods to rename your code and alter flowpaths to obscure it.
Consider using an obfuscator.
If you are developing desktop applications converting your code to Dll will not hide the it( there are many tools to decompile the dll or exe files).
but if you are using Asp.Net, then you can compile your site to Dll, and the code will not be visible in the aspx pages, it will be compiled to Dll, you can do that by right click on your project on solution explorer, then choose Publish website
But in all cases .Net Exe files and DLL will be easy to decompile and extract the source code again, unless you use tool to obfuscator your code.
If you mean, the end-user can view your source code by decompiling it, you can protect yourself using an obfuscator.
There is standard obfuscator build in into Visual Studio. In the menu choose Tools / Dotfuscator community edition.
I think my reply to a similar question about JavaScript obfuscation applies here as well: in short, why bother? Your question has already been answered here ("use an obfuscator"), but I thought it wouldn't hurt to find out what your motivations are. Generally, code that you give to people is "in the hands of the enemy" -- if somebody wants to use it/figure out how it works badly enough, they will.