Pelco Developer Network (PDN)

FileNotFoundException when using C# wrapper

I'm trying to do this:
The problem is I have the right path to the MediaController (in fact, at runtime the property Exists of the path is set to true). I'm using Visual Studio 2017, and CSharpWrapper is imported in my main project (it does compile, so I can use VXSystem for example, but crashes at runtime).
Idk what can I do to fix this.

What File is not found that is throwing the exception? Do you have GStreamer installed?

Check your files where the MediaController project is located. Is there a 'ThirdParty', directory, with GStreamer and the files in the folders there? It sounds like something there could be missing.

Something that is important to know is that the VX SDK does NOT perform streaming inherently. There must be a vehicle to use for streaming, and in our samples we use GStreamer (just like what VideoXpert Ops Center also uses). You'll need to review and understand each piece of the sample if you're trying to develop code.

We recommended that you use the sample code to learn how to utilize the SDK and how it uses GStreamer. Not every partner decides to use GStreamer; some use other tools and some write their own streaming solution. Using that information and knowledge, you should write your own code.

"System.IO.FileNotFoundException: 'No se puede cargar el archivo o ensamblado 'CPPCli.dll' ni una de sus dependencias. No se puede encontrar el módulo especificado"
The reference to the Wrapper at Visual Studio is:
The path to the CPPCli.dll file is:

Thank you for the follow up message.

Do you have a mis-match of some sort using Release vs Debug in your development environment?

Are you trying to deploy a Debug-built version to a PC without Debug libs? -- Because if you're doing this, that could be the problem. You must build the project in Release and then install the Visual Studio Redists to the client PC where you are trying to run the sample. We've seen that problem before. Be sure that you are using the Release versions of CPPCli if you are trying to run samples on other locations where Visual Studio isn't installed for the debug versions.

There were some additional posts to this forum topic here: that were removed when we had to roll back our website server. On that post, one user commented that he was having the exact same problem: "File not found" exception with CPPCli wrapper from the sample code. It worked in his development environment but not on another PC. The problem was that he was trying to use a debug dll on a PC without any development studio. He needed to build the sample in Release mode, use the Release version of CPPCli, and ensure that the proper Visual Studio Redists were installed on the other non-development PC.

At the end of the day, it is some kind of configuration issue like this that is the problem. It may be permissions, or it may be something missing. In your original post, you indicated that you've imported the existing CSharpWrapper project into yours... Does the sample code work properly on it's own without being imported to your project? If you download the Sample from GitHub and just run that, does it work?

If you're still totally stuck, please be sure to answer all of my individual questions. It may be something that you'll need to figure out in your environment, if you're trying to simply import our sample into your existing project.

Hi again,
Sample code does work, in fact I it's not the first application I develop with this computer, always using debug mode and never had a problem.
I tried to use realease mode just in case, but had no effect (path was updated and had CCPCli.dll, but throwed the exception).
Is there any environment variable I may be missing?

Hi, thanks for adding some more information. Our thoughts are that it is probably a PATH issue (similar to what you're suspecting). I've asked another developer who has worked with the VX SDK and samples a lot more than I have for some feedback to help out.

The sample will compile and more than likely copy over the CPPCli dll to the main apps output dir, which is where it will run from. The relative path you're seeing probably works for the C# wrapper project on its own, but not when the dll is copied over to the new output path.

You could try setting an absolute path to quickly see if that's the issue (another dev pointed out that is what the C++ samples do). Copy the gstreamer dirs to the target dir path, and that way they are always in the same relative location.

Please review these suggestions as they relate to your project where you're trying to use the wrapper.

Hi again,
I know it's been a while, but I've got a break from work.
I have achieved to make it work, i didn't see that you have to insert a pre-build command. Just in case someone runs into the same problem I'll post the steps to follow:
1 - Go to main project properties
2 - Go to "Build Events"
3 - Copy the next line
COPY /Y "$(ProgramFiles)\Pelco\VideoXpertSDK\SDK\$(PlatformTarget)\$(Configuration)\Bin\*" "$(TargetDir)"
COPY /Y "$(ProjectDir)..\..\MediaController\Bin\$(PlatformTarget)\$(ConfigurationName)\*" "$(TargetDir)"

Once I did this (plus the previous things at this post) It worked like a charm
Regards, Antoni

Thank you very much for following up with the information that worked for you on this question. It will no doubt help any others who encounter similar issues in the future and may be going down the same path.