interop

How to unregister my .net assembly when it's no longer in the same location?

孤街醉人 提交于 2019-12-03 16:15:46
I have a dll that's registered for com interop, so under HKLM\Software\Classes\CLSID[my guid]\InprocServer32[my version no]\Codebase it has the path of the registered dll. However, I've rearranged my folder structure so that path is no longer correct. Is there a way of unregistering that dll without putting it back, then unregistering, then removing the file again? And what if I don't have that dll any more, or only have one with a different version number? Different version numbers (generally) do not matter. As long as the newer DLL contains all the GUIDs which appear in the older version, it

Are there features of R that are system-dependent?

被刻印的时光 ゝ 提交于 2019-12-03 15:56:28
My co-workers would like to make sure that our work in R is platform-independent, specifically that code will run on Linux, Mac, and Windows, and that files created on one system will work on other systems. Since the issue has come up before in my group, I would appreciate a general answer that will make it easier for me to confidently assure my collaborators that there will not be an issue. E.g., it would help to have a reference other than "because (subject matter expert) said so on SO". Generally, is there a way to know if any features of R are platform-specific (can I assume that this

How do I create a Microsoft Jet (Access) database without an interop assembly?

﹥>﹥吖頭↗ 提交于 2019-12-03 15:42:18
I need to create an access (mdb) database without using the ADOX interop assembly. How can this be done? Before I throw away this code, it might as well live on stackoverflow Something along these lines seems to do the trick: if (!File.Exists(DB_FILENAME)) { var cnnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DB_FILENAME; // Use a late bound COM object to create a new catalog. This is so we avoid an interop assembly. var catType = Type.GetTypeFromProgID("ADOX.Catalog"); object o = Activator.CreateInstance(catType); catType.InvokeMember("Create", BindingFlags.InvokeMethod, null, o,

Exposing .net methods as Excel functions?

笑着哭i 提交于 2019-12-03 15:10:55
I have a set of calculation methods sitting in a .Net DLL. I would like to make those methods available to Excel (2003+) users so they can use them in their spreadsheets. For example, my .net method: public double CalculateSomethingReallyComplex(double a, double b) {...} I would like enable them to call this method just by typing a formula in a random cell: =CalculateSomethingReallyComplex(A1, B1) What would be the best way to accomplish this? There are two methods - you can used Visual Studio Tools for Office (VSTO): http://blogs.msdn.com/pstubbs/archive/2004/12/31/344964.aspx or you can use

.tlh generated on 2 machines is different

只愿长相守 提交于 2019-12-03 14:22:49
I have a .NET dll which has some interfaces\classes which are exposed to com. during the build procedure a .tlb file is generated and this tlb is referenced by some c++ code. As a result the compiler generates a .tlh file for the tlb. When I run the build locally one of the properties in one of the interfaces ends up with a corresponding method in the tlh which does not have the same name. The property in the .net code is called PropertyA end up being called get_propertyA, while PropertyB ends up called get_PropertyB. I didn't bat an eyelid when this happened, just used the method as defined

Send C++ string to C# string. Interop

笑着哭i 提交于 2019-12-03 14:12:50
问题 I am new to inter process communication and need some help. I want to be able to send a string from a C++ program to a C# program. My problem is that the resultant string is gibberish. Here is my code: Sending program (C++): void transmitState(char* myStr) { HWND hWnd = ::FindWindow(NULL, _T("myApp v.1.0")); if (hWnd) { COPYDATASTRUCT cds; ::ZeroMemory(&cds, sizeof(COPYDATASTRUCT)); cds.dwData = 0; cds.lpData = (PVOID) myStr; cds.cbData = strlen(myStr) + 1; ::SendMessage(hWnd, WM_COPYDATA,

C++/CLI Inheriting from a native C++ class with abstract methods and exposing it to C#

自古美人都是妖i 提交于 2019-12-03 14:07:14
I've been googling around in circles trying to find an fully fledged example to this but to no avail. I have a C++ API that presents a number of classes that contain pure virtual methods for the developer to extend from. What I'm attempting to do is provide this interface to C# via the C++/CLI. I've managed to get the API compiled into the C++/CLI library and I've reached a sticking point as I'm new to this. I'm aware that I need to create a wrapper to expose the C++/CLI unmanaged class to a managed .net class but I've not found a solid example or discussion that shows how to do this with the

How to dynamically load a C# dll from a C++ DLL

限于喜欢 提交于 2019-12-03 13:43:47
I have a C++ application. This supports users' C++ plugin DLL's, it will dynamically load these DLL's and then be able to create and use the user's types dynamically. These user types derive from base types and interfaces defined in the main application's core library, so I hold user's objects as pointers to the base class and call the user's virtual functions to make their magic happen. Now I want to extend the plugin DLL's to allow managed DLL's (I care about C# mostly). I want all of the same magic to happen in C# plugin DLL's. How can I dynamically load these dll's, some how I think win32

Cannot call COM object created from STAThread from oher STA threads

房东的猫 提交于 2019-12-03 13:27:13
I am new to COM and trying to understand the difference between STA and MTA. I tried to create an example that would show that COM can manage calls to object created in STA that is not thread-safe. MyCalcServer class here is created using ATL Simple Object. The settings used are the same as in this article : Threading Model: Apartment Aggregation: No Interface: Custom MyCalcServer COM object is used in another C# project which is: class Program { [STAThread] static void Main(string[] args) { MyCOMLib.MyCalcServer instance = new MyCOMLib.MyCalcServer(); string output1; instance.ChangeValue(

COM Interop: What should I do to make a C# property usable as a VARIANT from VBA

半腔热情 提交于 2019-12-03 13:03:40
Say I have a C# Nullable DateTime? property that needs to be consumed by VBA through COM. public DateTime? TestDate { get ; set; } Unfortunately, Nullables are not visible through COM, so I would like to have the property return a something that will be seen as a Variant from VBA. Unfortunately, I'm not sure how this should be written. I tried using an object and a dynamic instead of DateTime? : while I can get the property value, I can't set it (I get Run-Time error '424' Object required errors from VBA). Note : I don't have issues with making my library COM Visible: everything works fine and