interop

C# - Excel Number Formatting Issue with International settings

戏子无情 提交于 2019-12-30 11:13:47
问题 I am trying to write to an Excel 2003 spreadsheet using c# 3.5. However I am unable to get this to function correctly across different country settings. The country settings are either English or German. These two settings have different decimal and thousands settings. Everything works fine unless a user has changed the decimal and thousands separators in the International settings of the Options screen. Can anybody help as I feel I can no longer see the wood for the trees and am missing

What are my options for C++ DLL to call a C# DLL?

☆樱花仙子☆ 提交于 2019-12-30 11:08:39
问题 I have a C++ DLL that needs to call a function (pass a value, return a value) in a C# class library. Is my only option to give the C# DLL a COM interface and call it from C++ with IDispatch? Is this the best method? 回答1: Couple of options available for you here Use a mixed mode C++/CLI assembly as a bridge between the C++ and C# DLL Use the a COM bridge by exposing several of the key C# types as COM objects. This can then be accessed via the C++ code by normal COM semantics 回答2: This project

What are my options for C++ DLL to call a C# DLL?

狂风中的少年 提交于 2019-12-30 11:07:07
问题 I have a C++ DLL that needs to call a function (pass a value, return a value) in a C# class library. Is my only option to give the C# DLL a COM interface and call it from C++ with IDispatch? Is this the best method? 回答1: Couple of options available for you here Use a mixed mode C++/CLI assembly as a bridge between the C++ and C# DLL Use the a COM bridge by exposing several of the key C# types as COM objects. This can then be accessed via the C++ code by normal COM semantics 回答2: This project

Monodroid, Interop betwen Java and C#

怎甘沉沦 提交于 2019-12-30 10:37:26
问题 We have a big Java application under Android ("big" just means it's too much work to translate the application). We must access to an engine written in .Net (this engine is also too "big" ...). This engine is only calculation. We therefore seek a solution with monodroid. Our main problem is interop betwen monodroid and Java. At this time, we get : call a Java function in a .jar library from a Mono application But we can not call and start a Java activity. Is it possible ? The second problem

Help in creating Zip files from .Net and reading them from Java

☆樱花仙子☆ 提交于 2019-12-30 10:12:07
问题 I'm trying to create a Zip file from .Net that can be read from Java code. I've used SharpZipLib to create the Zip file but also if the file generated is valid according to the CheckZip function of the #ZipLib library and can be successfully uncompressed via WinZip or WinRar I always get an error when trying to uncompress it using the Java.Utils.Zip class in Java. Problem seems to be in the wrong header written by SharpZipLib, I've also posted a question on the SharpDevelop forum but with no

How do I handle a failed DllImport?

你离开我真会死。 提交于 2019-12-30 10:10:31
问题 I'm attempting to write a C# managed class to wrap SHGetKnownFolderPath, so far it works on Vista, but crashes on XP due to not finding the proper function in shell32.dll, as expected. I want to have it set so I can fallback on a (admittedly hacky) solution using System.Environment.GetFolderPath if using XP. (Or, even better, if it can't find the funciton in shell32.) Is there any way to do this other then conditional compilation? My current code looks like: public abstract class KnownFolders

Convert System.Drawing.Bitmap to stdole.StdPicture

巧了我就是萌 提交于 2019-12-30 08:41:00
问题 I have a System.Drawing.Bitmap currently and I need to convert it into an stdole.StdPicture. Currently I'm using: var pic = (stdole.StdPicture)Microsoft.VisualBasic.Compatibility.VB6.Support.ImageToIPicture (MyDLL.Properties.Resources.Img); // this is a System.Drawing.Bitmap but I get a Compiler Warning: Warning 'Microsoft.VisualBasic.Compatibility.VB6.Support.ImageToIPicture(System.Drawing.Image)' is obsolete: '"Microsoft.VisualBasic.Compatibility.* classes are obsolete and supported within

COM interop object throws InvalidCastException in one project but not in other

拥有回忆 提交于 2019-12-30 07:28:09
问题 I have a COM object I imported in my test C# solution. Everything works fine and continues to do so. Then I imported the same COM object in my actual solution and as a test implemented the exact same lines as in the test project. When I run the real project I get an InvalidCastException Unable to cast COM object of type 'CTWebReport.WebReportCOMClass' to interface type 'CTWebReport.IWebReportCOM'. This operation failed because the QueryInterface call on the COM component for the interface

C# Excel : Correct way to get Rows and Columns count

只谈情不闲聊 提交于 2019-12-30 07:19:06
问题 I have problem with C# Interop Excel get valid range with big file https://www.dropbox.com/s/betci638b1faw8g/Demo%20Training%20Data.xlsx?dl=0 This is my file but real size is 1000 but I got 49998 I used standard code Excel.Application xlApp = new Excel.Application(); Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(txtbTrainPath.Text); Excel.Worksheet xlWorksheet = xlWorkbook.Worksheets[1]; Excel.Range xlRange = xlWorksheet.UsedRange; xlApp.Visible = true; xlWorksheet.Columns[5].Delete();

.NET Interop: Find All instances of of a running COM object with C#

江枫思渺然 提交于 2019-12-30 07:03:08
问题 Background I am automating some Office application (Word and PowerPoint) via command-line tool. One thing my tool needs to do is locate all the running instances of Word. I know how to get a reference to one of the instances... Object running_obj = null; { running_obj = System.Runtime.InteropServices.Marshal.GetActiveObject(progid); } catch (System.Exception) { //failed to find the object; } if (running_obj!=null) { var running_obj_type = System.Type.GetTypeFromProgID(progid); Microsoft