First I've installed the latest Edge Nuget Package. Then I'm running the basic hello world starting example and have been running into this error on Windows 2010 w/ Visual Studio 2015.
When I execute the same hello world code on OS-X I get this error.
Here's a break out of the locals variable tree. Looks like the error might be similar.
The code looks like this. It is literally copied from the README.md of the repo.
using System;
using System.Threading.Tasks;
using EdgeJs;
class Program
{
public static async void Start()
{
var func = Edge.Func(#"
return function (data, callback) {
callback(null, 'Node.js welcomes ' + data);
}
");
Console.WriteLine(await func(".NET"));
Console.ReadKey();
}
static void Main(string[] args)
{
Task.Run((Action)Start).Wait();
}
}
Resolved this problem by copying the folder edge into the bin folder.
Reference: https://github.com/tjanczuk/edge/issues/565#issuecomment-315343743
When you install Edgejs from nuget it creates an edge folder in your solution. Node.dll should be in your x64 & x86 folders.
Related
I tried to run my program using Visual Studio's Coderunner extension as well as from terminal with the scriptcs command.
My code is as follows:
using System;
namespace HelloWorldApplication {
class HelloWorld {
static void Main(string[] args) {
Console.WriteLine("hellowol");
}
}
}
The error message reads:
Unexpected named argument: Users/jfitz/Projects/C#/Projtest/test.cs
As mentioned in scriptcs/scriptcs issue 1188, this is from a scriptcs bug, which will be fixed in the next release (PR 1289 and commit 9e49b72)
In the meantime, pending the next 0.18 scriptcs release:
The workaround is the following:
instead of doing
mono scriptcs.exe /path/to/foo.csx
do:
mono scriptcs.exe -script /path/to/foo.csx
Jonas suggests in the comments:
For Visual Studio Code, add this to settings.json:
"code-runner.executorMap": { "csharp": "scriptcs -script" }
I created some add-in for excel in C#. In it is one public class for using in VBA. On my machine all works ok. When I install add-in on tester computer (I'm using InstallShield 2015 Limited Edition for Visual Studio to create setup file) I can't set object.
C# code
using System;
using Excel = Microsoft.Office.Interop.Excel;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace PMTAddin
{
[Guid("B2350EC1-522E-4B75-BB02-86BB0FD1A60E")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
public class PublicClass
{
public void test()
{
System.Windows.Forms.MessageBox.Show(
"test."
, "test"
, System.Windows.Forms.MessageBoxButtons.OK
, System.Windows.Forms.MessageBoxIcon.Error
);
}
private int GetWorksheetID(Excel.Workbook wb, string worksheetName)
{
int result = 0;
foreach (Excel.Worksheet ws in wb.Worksheets)
{
if (ws.Name == worksheetName)
{
result = ws.Index;
break;
}
}
return result;
}
[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type type)
{
Registry.ClassesRoot.CreateSubKey(GetSubKeyName(type, "Programmable"));
RegistryKey key = Registry.ClassesRoot.OpenSubKey(GetSubKeyName(type, "InprocServer32"), true);
key.SetValue("", System.Environment.SystemDirectory + #"\mscoree.dll", RegistryValueKind.String);
}
[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type type)
{
Registry.ClassesRoot.DeleteSubKey(GetSubKeyName(type, "Programmable"), false);
}
private static string GetSubKeyName(Type type, string subKeyName)
{
System.Text.StringBuilder s = new System.Text.StringBuilder();
s.Append(#"CLSID\{");
s.Append(type.GUID.ToString().ToUpper());
s.Append(#"}\");
s.Append(subKeyName);
return s.ToString();
}
}
}
In VBA project I checked reference to it on the list. It calls PMT.
VBA
Sub dsf()
Dim o As PMT.PublicClass
Set o = New PMT.PublicClass 'at this lane on other computer I got error 429. On my computer all work smoothly and method test is running.
o.test
End Sub
I thought that maybe it was something .NET Framework, but it is installed. Any ideas?
EDIT:
I create two diffrent version for bittnes, but the same error.
But I found some new info. In registry on my computer it looks like this
and on tester machine it looks like this
There are no CodeBase value... Do you think this is the problem? If it is, how I need to modify RegisterFunction method to correct this?
After long seeking I found the solution. It's kind of partial, because for 64 bit Excel we need to register library manually (maybe someone knows, how to add bat file to installation file).
I found the answer on this site.
While creating Install Shield instalation file we need to do two things.
Add .tlb file to application files (this step was done by me, before posting on stackoverflow)
Click right on project.Primary output file and choose properities like in screenshot (for *.tlb file we need to check the same, but without "COM Interop")
Without this the installer will not properlly register add-in in registry.
Install file created like this would register add-in for 32-bit excel only. If you want to use it also in 64-bit Excel you need to register library manually. I created simple bat file like this:
c:
cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319
regasm.exe "[pathToDLL]\AddInName.dll" /tlb:"[pathToDLL]\AddInName.tlb" /codebase
pause
Remember, that you need to run it with admin rights.
i can't use Syetem.Data.SqlClient.
this is my code
using System;
using System.Data.SqlClient; // <== error
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
i make this project from console, and input 'dotnet new' and restore.
what shold i do?
Have you added "System.Data.dll" to your project reference?
Add reference for SQL server data from project references. If there is not such option then run the Setup of visual studio select option Modify and then select SQL data option and run the setup.
Doing some explorer/shell stuff on Win8/64bit with WindowsAPICodePack. Having some problems with the propertysystem causing an AccessViolationException when iterating over fileproperties with x64 platform target. Seems to be some problem in PropVariant.cs. Switching to x86 fixes the problems, but causes incomplete directory listings (f.e. "etc" missing in system32/drivers). Any ideas?
using System;
using Microsoft.WindowsAPICodePack.Shell;
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;
namespace ApiCodepackTest
{
class Program
{
const string path = #"c:\windows\system32\drivers";
static void Main(string[] args)
{
var shellObject = (ShellFolder)ShellObject.FromParsingName(path);
showProperties(shellObject);
showItems(shellObject);
Console.ReadLine();
}
static void showProperties(ShellFolder folder)
{
var sys = folder.Properties.System;
foreach (var prop in sys.GetType().GetProperties())
{
try
{
var shellProperty = prop.GetValue(sys) as IShellProperty;
if (shellProperty != null && shellProperty.ValueAsObject != null)
Console.WriteLine(shellProperty.CanonicalName + " " + shellProperty.ValueAsObject);
}
catch{} //you should not pass!
}
}
static void showItems(ShellFolder folder)
{
foreach (var i in folder)
Console.WriteLine(i.Name);
}
}
I'm not really into pinvoke and c++ stuff, but I've recompiled the source with a little fix in PropVariant.cs :
//[FieldOffset(12)] original
[FieldOffset(16)]
IntPtr _ptr2;
and this fixed the issue
For anyone else finding this question, you can now avoid recompiling the source to achieve this bug fix.
As discussed in this answer, the open source WindowsAPICodePack is now being maintained by a different developer (Pierre Sprimont). It has been updated as recently as July 2022 and is available on GitHub or as a series of Nuget packages directly through Visual Studio. The developer's website discussing his fork of the project is here, which has links to each Github repo and Nuget page.
The AccessViolationException bug in PropVariant.cs discussed in the accepted answer by #Aleksey has been fixed, along with many other bug fixes and improvements (including support for .NET Core).
I have tried many different ways. I completed a compile with the NDK and when I run it on an emulator with the adp shell, I get no output.
mono-3.10.0 from a tarball
Here are my environment variables:
export CC=i686-linux-android-gcc
export SYSROOT=/home/XXUSERNAMEXX/Develop/android-ndk-r10d/platform/android-17/arch-x86
export PATH=/tmp/my-android-toolchain/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Here is my configure:
./configure --disable-mcs-build --host=i686-linux-android --prefix=/home/XXUSERNAMEXX/vmshare/workspace/HelloJni/jni/mono-2.0 --target=i686-linux-android --build=i686-linux-gnu
then just
make
then
make install
Then build a C# sample of just:
// HelloAndroid.cs
// Outputs HelloAndroid.exe
using System;
namespace HelloAndroid
{
class MainClass
{
public static void Main (string[] args)
{
Console.WriteLine ("Hello World!");
}
}
}
then I copy
mono-sgen
libmonosgen-2.0.so
HelloAndroid.exe
to an android directory of
/data/data/com.example.helloandroid
change all the permissions to 755
change all the ownerships to system:system
then type
./mono-sgen HelloAndroid.exe
in the adp shell
then I just get nothing.
no errors, no output, just the command line returns
You need to compile the .NET Assemblies (System.dll ...) like for regular host and to put them into Android.
In addition define MONO_PATH to mono runtimes.