C# Unable to add reference basic.dll - c#

Hi guys im just new in C# i came from a PHP background. I'm working on a RFID project which has RRU1861CSharp.dll which is dependent to basic.dll. I am able to add reference RRU1861CSharp.dll but when i'm trying to add reference basic.dll it says:
"basic.dll could not be added please make sure that the file is accessible, and that is a valid assembly or COM component".
I cant post picture sorry i don't have enough reputation.

You don't need to add the dependencies of RRU1861CSharp.dll to the project. It sounds like it's not a .NET assembly which is why you can't; however, you do have to ensure that it is installed on the final client/server where your app will run, along with all the other dependencies of RRU1861CSharp.dll.
It also has to be accessible on you dev machine to run the app from VS.
However, it is not a reference: References are only the things your app needs directly.

Related

Bruel & Kjaer 2250 SDK - How to setup a C# project from scratch?

I'm trying to write a C# project that makes use of Bruel & Kjaer 2250 SDK. The SDK installer installs a VisualStudio 2015 Windows Form C# project that I'm able to build.
The next step for me was to create a similar project from scratch, so trying to do this and following litterally the BK instructions what happens is that I'm not able to create an instance of of class RemoteAPI in BK.BasicEnv.Application namespace.
I get an exception that tells me these informations:
An unhandled exception of type 'System.NullReferenceException'
occurred in BasicEnvRemoteAPI.dll
Additional information: RemoteAPI - Construction: No Instance of
EnvOfficeModel.
The constructor call is very simple:
private RemoteAPI api;
...
api = new RemoteAPI();
So the ctor of RemoteAPI is failing because an instance of EnvOfficeModel is missing to it,
I've googled a lot and made some tests but the result is always the same for my own project while the B&K example is correctly starting and is able to create an instance of the RemoteAPI class.
I also tried to compare the two projects and I'm not able to find a different setting, then I tried to search the B&K installed files and the registry for some hint about the possible causes of this behaviour, but no way ....
If some of you had the same problem and could perhaps drive me to the correct information to solve this problem will be a great thing.
I know that also a REST interface is available to communicate with BK2250 but I would like to use the native communication driver if possile.
Thank you and kind regards.
I encountered the issue today,
Verify that you imported the dll in the project correctly (Should appear under References if not it's probably the second issue)
Verify that you are using the .NET Framework and not the .NET Core
I managed to get it working with a Windows Form application using the .NET Framework 4.7.2

Is it possible to reference a COM DLL without registering itself?

I have activated COM registration free DLL when deploying the application. In addition, I have set the Properties->Linker->Register Output to NO in my build process. However now my application which references the DLL no longer builds because it cannot find the reference. So my question is that is it possible to build the application that references the DLL without registering the dll?
Thanks!
You left no breadcrumbs to guess why registration is required to build your code. This is not normally necessary. One random guess is that you are using the Isolated property for a reference in a C# project for a COM component written in C++. Which is a very nice feature, it automatically generates the manifest entries so the program can run reg-free.
But those manifest entries need to come from somewhere if you don't write them yourself. Which is the registry if you use the Isolated property. Chicken-and-egg problem here, you have to register it so it can run unregistered :)
Keep in mind that you use reg-free COM on the user's machine, it isn't important on your dev machine.

Client Needed for COM Server Created in C#

I looked on StackOverflow, but did not see a posted question/solution for this (but maybe missed).
I am looking for a way to test my COM server that is created in C# (i.e. registered for COM interop). When I try and add a reference to the COM object in a different C# project I get the error "...COMTest.tld was exported from a .NET assembly and cannot be added as a reference." I tried from VB and, of course, the same error. The references for the new projects in C# and VB were done from the COM tab after selecting Add Reference when right clicking on the solutions. Finally, I went to Visual C++, but did not see a way to add the reference and access COMTest.
Thanks for looking and any help! Feel free to let me know if any clarification is needed.

Calling C# from ColdFusion

I've written a .dll in C# to change the permissions on a folder. I also wrote an .exe to test the .dll and it successfully changes the permissions. Now I'm trying to call the .dll from ColdFusion, but I'm getting an error about System/Security/IPermission not being found.
I'm assuming this is an interface in C# that ColdFusion can't find in any of the available assemblies on my system. I've added the System.Security assembly to my References in the C# project. Is there something else I need to do to make sure ColdFusion can find the interface?
Here's how I'm using the .dll:
<cfobject type="dotnet" name="permObj" assembly="#pathToDLLs#CoursePortal.dll" class="CoursePortal.Permissions">
<cfset permObj.revokePermissions(dir, username)>
I never could get it to work. I switched the DLL to an EXE and used <cfexecute> to call it. It's working fine now. The .NET code is called so infrequently it doesn't make much difference that it's a separate app.

getting error while adding dll reference in the c# .net windows application why?

i have download the code from the codeProject web site but while runnig this i got the reference error of the dll in the reference folder. the dll file is located in my bin/debug/
folder. still it not found it. when i add this file from add reference tag i give the error
that this is not valid com component.
please help in this
thanks in advance.
If the DLL is a COM library, you will need to register it manually using regsvr32. Then you can access it by name from the COM tab of the Add Reference dialog (see below).
(source: com.com)
If, on the other hand the DLL is native code as Jon Skeet suggested, you will only be able to use it by p/invoking to call its interface directly - if this is the case, it is best to create a class that acts as a wrapper around the DLL - that puts a layer of indirection between your code and all the p/invoke stuff so your code isn't too tightly bound to the interface of the DLL.
Well, you haven't said which project it is... but my guess is that you're trying to add a reference to a native code DLL, rather than either a COM library or a .NET class library.
If you provide more details, we're far more likely to be able to help you.

Categories