interop

.NET Object from VB6 without use of regasm.exe?

断了今生、忘了曾经 提交于 2019-11-27 18:58:13
问题 The software company I'm working for builds software for schools, and so our client machines are usually locked down in such a way it makes it pretty impossible for us to install anything on it. Our old system is primarily based on a (very large) MS Access project and so it gets around the access problems by just running from a local folder. I've been given the task of redeveloping some of the system into c# .NET - however it would be nice in the interim stages to have the ability to have the

C# COM DLL: do I use Regasm, or Regsvr32?

佐手、 提交于 2019-11-27 18:11:24
I am building a C# ActiveX DLL... do I use REGASM or REGSVR32 to register it? How do I register the 64-bit interface vs the 32-bit interface? You need to use regasm.exe to register both the 32 bit and 64 bit interfaces I believe you need to run each of the regasm.exe 's in: C:\Windows\Microsoft.NET\Framework\v2.0.50727 and C:\Windows\Microsoft.NET\Framework64\v2.0.50727 So... in your case you need to run the regasm.exe in the Framework64\v2.0.50727 folder. Here's an example we use to register a COM interop DLL for one of our legacy ASP apps: regasm.exe Hosting.DeviceManager.Power.dll /register

How to create an instance of Excel if Excel is not installed

梦想的初衷 提交于 2019-11-27 17:20:56
问题 In my C# app, with the help of Excel Interop dll (as reference) i am reading/writing excel files. If I move this program to system where office/excel is not installed (think of clean machine), i am hitting with below error. System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E

How to access static inner Java class via Clojure interop?

南笙酒味 提交于 2019-11-27 17:05:02
问题 Basically what I need to do is this FileChannel.MapMode.READ_ONLY I tried doing the obvious (.. FileChannel MapMode READ_ONLY) but that ends up throwing an exception java.lang.NoSuchFieldException: MapMode even the / notation specified as for access static fields in the interop documentation produces the same exception (. (FileChannel/MapMode) READ_ONLY) 回答1: You access inner classes with $ java.nio.channels.FileChannel$MapMode/READ_ONLY 回答2: The syntax (FileChannel/MapMode) is a

Call F# code from C#

一个人想着一个人 提交于 2019-11-27 16:58:00
I am playing around with F# and C#, and would like to call F# code from C#. I managed to get it to work the other way around in Visual Studio by having two projects in the same solution, and adding a reference of the C# code to the F# project. After doing this, I could call C# code and even step through it while debugging. What I am trying to do is F# code FROM C# instead of C# code from F#. I added a reference to the F# project to the C# project, but it isn't working the way it did before. I would like to know if this is possible without doing it manually. Eric Below is a working example of

How do multiple languages interact in one project?

[亡魂溺海] 提交于 2019-11-27 16:47:20
I heard some people program in multiple languages in one project. I can't imagine how the languages interact with each other. I mean there is no Java method like myProgram.callCfunction(parameters); never happens or am I wrong? Having multiple languages in one project is actually quite common, however the principles behind are not always simple. In the simple case, different languages are compiled to the same code. For example, C and C++ code typically is compiled into machine assembler or C# and VB.Net is compiled into IL (the language understood by the .NET runtime). It gets more difficult

keybd_event along with PostMessage win32 not working when Visual Studio has focus (or any application run as admin)

感情迁移 提交于 2019-11-27 15:52:18
This is a program that I have used with many changes from the old xp day's It's a cmd line program that will change track in media applications(Spotify,vlc,mediaPlayer) just like keyboards with next/previous track buttons. Currently im using Microsoft natural keyboard that does not have those buttons but have programmable keys that execute this prog. This all works EXCEPT when Visual Studio 2012/2013 has the focus (Windows 7) (haven't tried other versions), and it works in Sql management studio. using System; using System.Runtime.InteropServices; namespace NxtTrack { class Program { [DllImport

Initializing an array on arbitrary starting index in c#

戏子无情 提交于 2019-11-27 15:14:53
Is it possible in c# to initialize an array in, for example, subindex 1? I'm working with Office interop, and every property is an object array that starts in 1 (I assume it was originally programed in VB.NET), and you cannot modify it, you have to set the entire array for it to accept the changes. As a workaround I am cloning the original array, modifying that one, and setting it as a whole when I'm done. But, I was wondering if it was possible to create a new non-zero based array expedient You can use Array.CreateInstance . See Array Types in .NET James Boother It is possible to do as you

Call C++ native/unmanaged member functions from C# when member functions were not exported

半世苍凉 提交于 2019-11-27 14:15:59
问题 I have an unmanaged DLL that exports only a C style factory method that returns a new instance of a class (simplified here to look simple). hello.h #if defined(HWLIBRARY_EXPORT) // inside DLL # define HWAPI __declspec(dllexport) #else // outside DLL # define HWAPI __declspec(dllimport) #endif struct HelloWorld{ public: virtual void sayHello() = 0; virtual void release() = 0; }; extern "C" HWAPI HelloWorld* GetHW(); hello.cpp #include "hello.h" struct HelloWorldImpl : HelloWorld { void

Writing to an existing Excel File using c#

*爱你&永不变心* 提交于 2019-11-27 14:14:31
问题 I am trying to open (or create a new xls) Excel file and write some values to it. Although, the program below works just fine if I simply create a new xls file, I encounter the some problem in line **mWorkBook = oXL.Workbooks.Open (path, 0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);** Here's the error: 'LOG.xls' cannot be accessed. The file may be corrupted, located on a server that is not responding, or read-only. It