Use OxyPlot in Windows Universal app c++/xaml project - c#

I am new to windows app development. I want to use OxyPlot in UWAP C++/Xaml project. I am able to use it in C# based project but not in C++/Xaml project. First I tried to add it using Nuget package manager but it didn't install. Then I followed this (https://social.msdn.microsoft.com/Forums/en-US/8b77c775-21e0-4b43-b9f3-fb3777c43212/adding-libraries-and-use-them?forum=winappswithnativecode). In this Windows runtime component (with OxyPlot) is created in C# and used in C++ project. Here I am able to build the project but app crashes saying OxyPlot (added in C# project) not found.
Can someone please guide me. Regards

This may not 100% apply but it should. I was not trying to do this: "Use OxyPlot in Windows Universal app c++/xaml project". But I was tyring to use OxyPlot in a C++ .Net class so that it could do somethings fast, and eventually pass things back to a C# Class or WPF form. The idea I needed to know was could I create an OxyPlot.DataPoint array in C++ then put it into a C# Double array or an List in C# fast. And I can do that now fast! I hope this approach might help someone here doing this. I don't know how easy it is to use this technique to be able to use the opti chart in a C++ app or not. But if the GUI is done in C# this approach works.
I was getting the error: "You are trying to install this package into a project that targets 'native,Version=v0.0', but the package does not contain
any assembly references or content files that are compatible with that framework." when I tried to install OptiPlot.WPF or the NuGet.Commandline.
This may not be a complete solution for everyone's needs, but it worked for me. I found a "cheatin" way of getting OptiPlot.WPF into a sample C++.Net project. I had a C# main program project in my solution - I installed the package there:
Install-Package OxyPlot.Wpf -Version 2.0.0
Then I copied the packages.config file and the packages folder from there to my C++ .Net Class Library Project. Then I edited the packages.config file and took something out that didn't apply, and I probably took out a package in packages that wasn't needed. Then I added my references in the C++ .Net Class Library Project to packages/OxyPlot.Wpf.2.0.0 folder.
Now I could use the OxyPlot inside of C++! Cool!

Related

VSCode c# autocomplete not working on an added package

I am trying to build a library on top of and other library / framework.
I am doing this in C#, So at first i create a new project by doing
dotnet new console
Then i add the package which will serve as the basis for my library. I do this in the following way:
dotnet add package Veldrid
This works fine, i see it get added and it is visible in the .csproj
But then when i try to acces a function of a class or even create a new instance of a class from that package i see no autocomplete options what so ever :( But when i type my own class within the project its namespace autocomplete works all fine.
Why doesnt the autocomplete function work for added packages?
Extra information:
i am using a mac,
I have dotnet core 2.2.300 installed,
i am using vscode with the c# extension,
and in my project i have the using Veldrid added so i can use the package.
Let me know if something is unclear or extra information is needed!
side note:
I keep getting the message: Some projects have trouble loading. Please review the output for more details whenever i open a c# project in vscode.
after spending an age of googling and searching i found what was causing the problem for me.
I had unity installed which also installs the mono framework. (for me the mono framework caused all the problems). So i uninstalled unity and the removed the monoframework from my computer (mac) and all was well.
Hope this helps anyone in the future!
If there are better ways of going about this please let me know!

Is it possible to install the MaterialDesignThemes package once and be able to reference it on each and every other wpf project?

I am new in WPF application development and I came across the Material Design package, I am using Visual Studio 2015 Enterprise.
Every time I want to create a new WPF application I always go to
Project -> Manage NuGet Packages and install the MaterialDesignThemes package for that specific project and when I am working on another project I need to do the same process again.
Is possible to only install this package once and somehow use it (or reference it) on all projects that I am creating as opposed to installing it with each and every new project I create?
I hope my question makes sense and I am asking this for the sake of being able to develop new material design WPF applications offline.
They ask to use nugget to keep the package updated that way you can check versions and so on. But you can download the source code from GitHub and keep it on your machine or server you use it for. That way you can refer it from your machine and don’t need to download for every project you work.
Project source: https://github.com/ButchersBoy/MaterialDesignInXamlToolkit/releases
In my opinion, I highly recommend download from nugget repository because it is easy to maintain and anyone else that code and the same project will find the package over there.
Create a Project Template.
VS2015: https://msdn.microsoft.com/en-us/library/xkh1wxd8.aspx
VS2017: https://learn.microsoft.com/en-us/visualstudio/ide/how-to-create-project-templates
Another way of quickly installing nuget packages is using the Package Manager Console and use the install-package command. e.g. install-package materialdesignthemes

Using/handling bitcoin in Unity3d game

I need to handle bitcoin in my unity project
I tried to install some nuget packages to support that
like this for example : https://github.com/blockchain/api-v1-client-csharp
but I always get this error
Could not install package 'BlockchainAPI 2.0.0'. You are trying to
install this package into a project that targets
'.NETFramework,Version=v4.0', but the package does not contain any
assembly references or content files that are compatible with that
framework. For more information, contact the package author.
unfortunately - no current unity3d plugins that support bitcoin yet
any suggestions , solutions ?
The plugin is using .NET version that is > Unity's supported .NET version.
The easiest solution I know about is to download the project directly from the link you posted.Delete any file that is NOT a C# file(.cs). Extract those folders with the remaining files and put them in your Unity project. Now look for errors. If you find any script with an error or script that uses C# 4 classes, modify it and fix the errors by hand.
This is easier than trying to implement your own bitcoin API from scratch.
NOTE: The only reason I recommend this method is because I looked inside the project and there were no DLL files inside it. So it is possible to port it if there is no DLL file in the API. Assuming there were DLL files compile with C# 4, then that would be a problem.
There's a beta edition of Unity that now supports a newer Mono version, which can let you compile .NET 4.5.2 (or older) projects.
I recommend you Nicolas Dorier's NBitcoin library for this then.

How do you install a Windows Runtime Component built in C++/CX into a C# project?

I have a library called foo, which is written in C++/CX. I chose a Windows Runtime Component because I want it to be projected into C#, C++ and JavaScript. Also, I want to be able to distribute the library, and I don't want to require/allow the consumer to load my project, along with the source files, in the same solution as their project.
The instructions on MSDN only demonstrate how to include the Windows Runtime Component project in a solution with the consuming C# project. I know there is a way to only distribute the binary, but I don't know how.
This question has been asked a thousand times, but the answer always has the two projects in the same solution, is incomplete or a workaround.
I'm using Visual Studio 2013.4 on Windows 8.1.
One way to do it is to create a VSIX package of your component. See Walkthrough: Creating an SDK using C++ that shows exactly how to do this with a WinRT component consumed by a C# project.
I researched and found the answer... It is not documented well, it is not intuitive, but it's worth the trouble when you see how well a Windows Runtime Component works.
Compiling the C++/CX library:
Make sure you compile the library for all permutations of Debug and Release, in Win32, ARM, x86 and x64.
Instructions for consuming in C#:
Right-click on References in the Solution Explorer, and add a reference to the Microsoft Visual C++ Runtime Package v12.0. Then add a reference to the binary you created with the appropriate configuration for your project (i.e. Debug/ARM). This step is tricky, because the file filter prompts you for the .dll, but you need to set the filter to *.* and select the .winmd file. Then you unload the project, find the <Reference> tag for the library you just added. <Reference> will have a <HintPath> tag below it, and under <Reference> you will also need to add <IsWinMDFile>true</IsWinMDFile> and an <Implementation> tag pair loaded with the name of the .dll that was sitting in the same folder as the .winmd file.
For more detailed instructions and information, I highly recommend visiting Mike Taulty's Blog

Using SQLite-net in a WPF app

I'm having a bit of a senior moment trying to get SQLite working on a new WPF project. I've recently written a bunch of Windows Store and Phone projects and always used the same neat SQLite-net implementation there, but now I can't seem to do that with my WPF app.
I've added SQLite-net through nuget, but I can't find a version of SQLite3.dll that I can add to the project. When I download it from SQLite.org I get the following error.
What am I doing wrong? All the tutorials I find tell me to use System.Data.Sqlite instead but I don't want to rewrite all my DAL code again
I got it working.
For anyone who's trying to do this - specifically, trying to get sqlite-NET to work on WPF, not just SQLite, you need to:
download the pre-compiled windows binary of sqlite3.dll from http://www.sqlite.org/download.html
copy that dll file into your bin folder
go to project properties > build and change the CPU type to x86 (there's no precompiled x64 version at time of writing)
You need to download and install an appropriate System.Data.SQLite setup package from http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki.
This will install the required SQLIte assemblies into your GAC and the design-time components for Visual Studio.
For .NET 4.5.1 (VS 2013) the current link is http://system.data.sqlite.org/downloads/1.0.92.0/sqlite-netFx451-setup-bundle-x86-2013-1.0.92.0.exe
For .NET 4.5 (VS 2012) the current link is http://system.data.sqlite.org/downloads/1.0.92.0/sqlite-netFx45-setup-bundle-x86-2012-1.0.92.0.exe
For .NET 4 (VS 2010) the current link is http://system.data.sqlite.org/downloads/1.0.92.0/sqlite-netFx40-setup-bundle-x86-2010-1.0.92.0.exe
Once you do that you will be able to add required SQLite assembly references in your project.
Here is a screenshot of SQLite assemblies in Add Reference dialog:

Categories