Skip to content

Navigation Menu

Sign in
Sign up

How to use Psi after building from source (specifically for components which require source build) #167

Unanswered
trigaten asked this question in Q&A
Discussion options

Psi
After building Psi from source, I have the folders/files in the image.

If I make a new project in the Psi solution, how do I use Psi components? I tried using Microsoft.Psi in the default Program.cs of a basic Console App, but the compiler can't find the Microsoft.Psi package. Are there any tutorial videos that go through developing after building from source?

You must be logged in to vote

Replies: 2 comments 10 replies

Comment options

You'll need to first add Microsoft.Psi (and any other class libraries of components you might need) as "Project References" to your project. In Visual Studio, this can be done by right-clicking on your new project, selecting "Add -> Project Reference..."

image

For example, once you've added the Microsoft.Psi project reference, your new project's .csproj file will look something like the following:

<Project Sdk="Microsoft.NET.Sdk">
 <PropertyGroup>
 <OutputType>Exe</OutputType>
 <TargetFramework>netcoreapp3.1</TargetFramework>
 </PropertyGroup>
 <ItemGroup>
 <ProjectReference Include="..\Sources\Runtime\Microsoft.Psi\Microsoft.Psi.csproj" />
 </ItemGroup>
</Project>
You must be logged in to vote
1 reply
Comment options

Thank you. I followed your instructions and added these items to the .csproj:

<ItemGroup>
 <ProjectReference Include="..\Sources\Imaging\Microsoft.Psi.Imaging\Microsoft.Psi.Imaging.csproj" />
 <ProjectReference Include="..\Sources\RealSense\Microsoft.Psi.RealSense.Windows.x64\Microsoft.Psi.RealSense.Windows.x64.csproj" />
 <ProjectReference Include="..\Sources\RealSense\Microsoft.Psi.RealSense_Interop.Windows.x64\Microsoft.Psi.RealSense_Interop.Windows.x64.vcxproj" />
 <ProjectReference Include="..\Sources\Runtime\Microsoft.Psi.Interop\Microsoft.Psi.Interop.csproj" />
 <ProjectReference Include="..\Sources\Runtime\Microsoft.Psi.Windows\Microsoft.Psi.Windows.csproj" />
 <ProjectReference Include="..\Sources\Runtime\Microsoft.Psi\Microsoft.Psi.csproj" />
 </ItemGroup>

I ran a simple code snippet:

using System;
using Microsoft.Psi;
using Microsoft.Psi.RealSense.Windows;
namespace ConsoleApp1
{
 class Program
 {
 static void Main(string[] args)
 {
 var p = Pipeline.Create();
 RealSenseSensor r = new(p);
 //r.ColorImage.Do(t => Console.WriteLine(t));
 p.RunAsync();
 Console.ReadKey();
 p.Dispose();
 }
 }
}

but I get the following error:

BFE

I have the correct reference in the .csproj (I believe?).

Why might this error be occurring?

Comment options

This error usually indicates a mismatch in the project's platform target settings. The RealSense component is x64 only, so your project's Platform target also needs to be x64, as shown below:
image

You must be logged in to vote
9 replies
Comment options

I built that, but it did not fail.

Comment options

I don't have any other good suggestions. The Psi team probably have better insight into it.

If you are open to trying other random debugging tricks, here's some things I would try/validate:

  1. Delete the bin/obj folder in your project directory and rebuild. See if it works after that.
  2. Check if the dll file is in same folder as your generated bin file. The path should be like PROJECT/bin/debug/net472/. If its not there, try copying it from the other folders.
Comment options

Could you also try modifying your .csproj file as follows (replacing/deleting AnyCPU):

<Project Sdk="Microsoft.NET.Sdk">
 <PropertyGroup>
 <OutputType>Exe</OutputType>
 <TargetFramework>net472</TargetFramework>
 <Platforms>x64</Platforms>
 </PropertyGroup>
 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
 <PlatformTarget>x64</PlatformTarget>
 </PropertyGroup>
 <ItemGroup>
 <ProjectReference Include="..\Sources\Imaging\Microsoft.Psi.Imaging\Microsoft.Psi.Imaging.csproj" />
 <ProjectReference Include="..\Sources\RealSense\Microsoft.Psi.RealSense.Windows.x64\Microsoft.Psi.RealSense.Windows.x64.csproj" />
 <ProjectReference Include="..\Sources\RealSense\Microsoft.Psi.RealSense_Interop.Windows.x64\Microsoft.Psi.RealSense_Interop.Windows.x64.vcxproj" />
 <ProjectReference Include="..\Sources\Runtime\Microsoft.Psi.Interop\Microsoft.Psi.Interop.csproj" />
 <ProjectReference Include="..\Sources\Runtime\Microsoft.Psi.Windows\Microsoft.Psi.Windows.csproj" />
 <ProjectReference Include="..\Sources\Runtime\Microsoft.Psi\Microsoft.Psi.csproj" />
 </ItemGroup>
</Project>
Comment options

I did this, but the same issue occurs.

Comment options

I don't have any other good suggestions. The Psi team probably have better insight into it.

If you are open to trying other random debugging tricks, here's some things I would try/validate:

  1. Delete the bin/obj folder in your project directory and rebuild. See if it works after that.
  2. Check if the dll file is in same folder as your generated bin file. The path should be like PROJECT/bin/debug/net472/. If its not there, try copying it from the other folders.

1: Tried, but no luck.
2: There is no debug folder in PROJECT/bin. Is that an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /