I have a C# project using the ImageMagick library Magick.Net Q16 AnyCPU net40 targeting .Net 4.7.2 using VS 2022. After upgrading this from 7.4.6 to 11.2.1 using Nuget Package Manager the function image.AddProfile (where image is an ImageMagick image) is flagged as not present using the code below:
using (MagickImage image = new MagickImage(sFileIn))
{
image.AddProfile(ExifProfile1);
The function image.AddNoise is present. I have a 'using ImageMagick' statement in the namespace. Looking at the ImageMagick namespace, AddProfile is defined as shown below:
public unsafe void AddProfile(string? name, byte[] datum, int length)
How can I access the AddProfile function in this version of ImageMagick?
You can find your answer in the release notes: https://github.com/dlemstra/Magick.NET/releases/tag/7.16.0.0. The AddProfile method has been renamed to SetProfile.
Related
I am new to C# and I am trying to create a bitmap object in C# in Visual Studio 2019, but it isn't working. I have .NET Framework updated to the latest version and I have resharper installed. I am using Windows 10.
Ive tried adding the references manually with Add/Reference... and it does not stay checked.
I added using system.drawing and using system.drawing.common to the top of my code.
I updated my .net core and enabled it in my project.
using System;
using System.Drawing.Common;
namespace Bot
{
class Program
{
static void Main(string[] args)
{
var bmp = new Bitmap();
}
}
}
I expected it to create a bitmap object, but it won't compile and gives me errors saying that the bitmap object does not exist in system.drawing.
The Bitmap class if part of the assembly System.Drawing.Common.dll, so you need to install System.Drawing.Common via the Nuget Package.
It looks like you don't have the package in your system/project.
In you're project directory or from VScode terminal do this:
dotnet add package System.Drawing.Common --version 6.0.0
then add a reference to the package in you're project
I have the below snippet of code to test/use dotnet 2.1 in vs 2017 in order to try out and run C# 7.2s Span functionality.
Where can I find the SDK that allows me to run this within Visual Studio.
I can only find frameworks up to 2.0.
using System;
using System.Memory;
namespace sim
{
class Program
{
static void Main(string[] args)
{
var arr = new byte[10];
Span<byte> bytes = arr; // Implicit cast from T[] to Span<T>
Span<byte> slicedBytes = bytes.Slice(start: 5, length: 2);
}
}
}
Otherwise I'm left unable to run and use
Error CS0305 Using the generic type 'Memory' requires 1 type arguments sim
You do not need to install any SDK for using Span<T>
You need to install System.Memory nuget package which is prerelase version.
you can use this command
Install-Package System.Memory -Version 4.5.0-preview2-26406-04
You also need to set your language version to 7.2 in your project properties and also you need Visual Studio 15.5 or more
Have you tried this? .NET Core SDK 2.1.4
I have the C# VSC extension as well as the NuGet Package Manager installed. Here is my VSC version info:
First, I create a brand new console application in VSC with the command:
dotnet new console
This gives me the code:
using System;
namespace ReferenceTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
I now want to create a using System.Windows.Forms; reference. When I start typing this using statement however, intelli-sense fails me:
I found this question/answer already but in step #5 the autofill option shown is not there:
When I try to improvise and follow other instructions I've found in my searching by using the
NuGet Package Manager: Add Package
option, I cannot select System.Windows.Forms
I have looked for a project.json file per the instructions of several sites but I can only find a project.assets.json file and it doesn't look very similar to what I see in the examples I find. This issue is not only for System.Windows.Forms but other references I try as well.
Windows Forms and WPF applications are not supported in .NET Core, only in .NET Framework.
have a look at the following article:
https://stackify.com/net-core-vs-net-framework/
As the title says, I want to change the .NET Target Framework Version for my C++ project. I'm trying to compile with the /clr command which I think should enable it?
Here's a screenshot:
I'm trying to build a DLL for use in Unity and I want to be able to select the proper framework.
I've tried changing the information in the .vxproj file but I can't find the right tag and when I add it myself it throws errors.
EDIT:
this is the code that contains the methods that can be called in C# to use the C++ code I've written before. I only edited the .h file of the CLR Class library (so the .cpp file is only including the header which should be fine I think)
#pragma once
#include "PortAudioManager.h"
using namespace System;
namespace PortAudioWrapper {
public ref class PortAudioManaged
{
private:
PortAudioManager* audioManager;
public:
PortAudioManaged() : audioManager(new PortAudioManager()) {
}
virtual ~PortAudioManaged() {
this->!PortAudioManaged();
}
// = Object.Finalize
!PortAudioManaged() {
delete audioManager;
audioManager = nullptr;
}
void openStreamManaged() {
audioManager->openStream();
}
void stopStreamManaged() {
audioManager->stopStream();
}
};
}
You should be able to follow the guide at https://msdn.microsoft.com/en-us/library/ff770576.aspx
The .NET framework you can target in C++ is dependent on the toolset you choose. You may find it easier to just download an older version of VS that supports the framework you're looking to work with.
In project file I just created the section looks like the below:
<PropertyGroup Label="Globals">
<ProjectGuid>{48ACEC98-3369-486F-9033-8C433D408570}</ProjectGuid>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<Keyword>ManagedCProj</Keyword>
<RootNamespace>ClassLibrary1</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
Using VS2015, I had to upgrade the .Net target of a managed C++ DLL from 3.5 to 4.5.1. In the Configuration Properties-General settings, the ".Net Target Framework Version" is greyed out and its value box is not editable.
Open the Name.vcxproj file in notepad.
Navigate to: "<"PropertyGroup Label="Globals" ""
Add: "<"TargetFrameworkVersion""v4.5.1"<"/TargetFrameworkVersion"
Save the updated project file, and reload into VSS2015.
NOTE: Remove the "" around the angle brackets.
Then when the project is reloaded into VS2015, you can see the .Net version listed in settings. In my case it was V4.5.1.
I am trying to include GPU using OpenCvSharp. I installed the OpenCvSharp by using Nuget Package Manager in Microsoft Visual Studio 2013.
I have included these lines already
using OpenCvSharp;
using OpenCvSharp.CPlusPlus;
using OpenCvSharp.CPlusPlus.Gpu;
but when i check the device count
//GPU
int count = Cv2Gpu.GetCudaEnabledDeviceCount();
//int count = Cv2Gpu.ge
Console.WriteLine("The GPU Device count is " + count.ToString());
it always returns 0.
Now it also says if OpenCv is not compiled with CUDA then it always returns 0.
it does not even get DeviceDetails.
I have resolved this problem by building the opencv_core.dll and opencv_gpu.dll.
Make the source code of opencv with Cmake and dont forget to select "withcuda" option while configuring the source code first.
after generation then open OpenCv solution in build folder and first build opencv_core and then opencv_gpu.
once you got the dll in the bin folder replace them in the opencvsharp package folder. Now build the project again. Now the project will copy the new dll's to the required folder.