VS 2022 c# 'type or namespace name 'DllExport' could not be found' - namespaces

This is from a c# dll from GitHub that is in use by many people so it should compile but this line
[DllExport(CallingConvention.StdCall)]
gives these errors
Error CS0246 The type or namespace name 'DllExport' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'DllExportAttribute' could not be found (are you missing a using directive or an assembly reference?)
That is the only line in the code with an error.
using System;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Windows.Services.Store;
...
[DllExport(CallingConvention.StdCall)]
...

From what I have gathered with your specific line of code there
[DllExport(CallingConvention.StdCall)]
DllExport is a function from the UnmanagedExports library, so you just need to add:
using RGiesecke.DllExport;

Related

services.AddDatabaseDeveloperPageExceptionFilter(); error code: CS1061

i'm coding like below
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<SchoolContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddDatabaseDeveloperPageExceptionFilter();
services.AddControllersWithViews();
}
but i got a error message
Error CS1061 'IServiceCollection' does not contain a definition for 'AddDatabaseDeveloperPageExceptionFilter'
and no accessible extension method 'AddDatabaseDeveloperPageExceptionFilter' accepting a first argument of type
'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)
AspCore_DB C:\Startup.cs 30 Active
this code is officially introduced in the MS guide and i just followed. i'm working on MS Visual studio 2019 v16.8.2
After doing some research I found that this is in the Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore library.

Hangfire MySqlStorage - HttpConfiguration does not contain a definition for 'UseStorage'

I'm trying to use Hangfire MySqlStorage in Web API app with mysql DB. I installed NuGet package "Hangfire.MySqlStorage" version 1.0.3. When I'm configuring Hangfire I'm getting following error,
HttpConfiguration does not contain a definition for 'UseStorage' and
no extension method 'UseStorage' accepting a first argument of type
'HttpConfiguration' could be found (are you missing a using directive or an assembly reference?)
Seems I'm missing a reference here. Could not figure out.
It seems you are calling the method on the wrong object.
It should be, as per the documentation:
GlobalConfiguration.Configuration.UseStorage(
new MySqlStorage(connectionString));
Where GlobalConfiguration is actually Hangfire.GlobalConfiguration from the Hangfire.Core library.

Nancy doesn't find system.xml

I have a Nancy view with a using statement:
#using System.Xml
#{ //code
}
<!-- rest of page -->
System.Xml is referenced in my project.
When I try to run the app I get a Razor Compilation Error:
Error compiling template: Views/index.cshtml
Errors:
[CS0234] Line: 1 Column: 18 - The type or namespace name 'Xml' does not exist in the namespace 'System' (are you missing an assembly reference?) (show)
Details:
#using System.Xml
Other namespaces, e.g. System.Web also fail in the same way, even though they are included in the project.
Ideas?
This looks like a classic case of not configuring razor.
https://github.com/NancyFx/Nancy/wiki/Razor-View-Engine#configuring-razor

Changing namespace name of C++ component in Windows Phone causes exception

I have a C++ runtime component in a WP8 application, and if I change the namespace name, I get a "TargetInvocation" exception thrown whenever I try to instantiate a class in that namespace.
As an example, if I create the default C++ Windows Runtime Component, the header looks like this:
#pragma once
namespace CppComponent1
{
public ref class WindowsPhoneRuntimeComponent sealed
{
public:
WindowsPhoneRuntimeComponent();
};
}
If I change CppComponent1 to CppComponent2 in the .h and the .cpp, and then try to instantiate a WindowsPhoneRuntimeComponent object in my C# code, I get the following error:
A first chance exception of type 'System.TypeLoadException' occurred in Unknown Module.
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in Microsoft.Phone.ni.dll
How can I change the namespace of a native module in a WP8 app? Thanks!
The name of the Windows Metadata (WinMD) file that declares the component must be a prefix of the namespace in which the public types are declared. (I provided a slightly more detailed explanation of the namespace rules in an answer to another question.)
If you rename the namespace from CppComponent1 to CppComponent2, you also need to rename the WinMD file produced by the build from CppComponent1.winmd to CppComponent2.winmd.

method in Report Builder custom assembly not found

I'm trying to use a custom assembly in Report Builder 2.0. I have added the assembly to the report via Report Properties > References. When I try to call a public static method in the assembly, I get this message:
'ExtractTag' is not a member of 'ReportsClassLibrary.ReportsClassLibraryTools'.
The expression I'm trying to use to call the method is:
=ReportsClassLibrary.ReportsClassLibraryTools.ExtractTag("ID", "ID:incorrect", false)
And the method signature in the assembly is:
public static string ExtractTag(string tagToFind, string tags, bool caseSensitive)
That method is within the ReportsClassLibrary namespace and in the ReportsClassLibraryTools class.
I don't know if for some reason my report is looking an older version of the assembly that did not have this method, or if the problem is something else. I've tried removing the assembly from the report, rebuilding the assembly, and re-adding it to the report.
Edit: looks like a deeper problem. My assembly compiles, but when running a test case that calls that method, the test fails with a System.MissingMethodException. Guess I'm having an assembly problem, not a Report Builder problem...
Turned out it was a problem with the Global Assembly Cache in Vista. The old version of my assembly was cached, so the new method ExtractTag wasn't part of the assembly. I had to run:
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe" /i bin\Debug\ReportsClassLibrary.dll