interop

Create advanced filter

冷暖自知 提交于 2019-11-29 17:14:16
I am trying to create an advanced filter in Excel from C# to copy unique data from one sheet to another, at least I get it in Excel and if I use Interop like this : Excel.Range rang = sheet2.get_Range("A2"); Excel.Range oRng = sheet.get_Range("I2", "I" + (lst.Count + 1)); oRng.AdvancedFilter(Excel.XlFilterAction.xlFilterCopy, CriteriaRange: Type.Missing, CopyToRange: rang, Unique: true); Works fine but I'm doing all my application with EPPlus and it will be better if I can do the same without Interop. So, it is possible? Since Advanced Filter is an excel function you need the full Excel DOM to

marshalling a struct containing string

孤人 提交于 2019-11-29 16:55:32
i basically want to take int name and string age from user in c# and send it to dll method written in c which take int and char[50] arguments in it and return string .i created following scenario but i am failed ,any body has the code i have a dll developed in c which ahas a structure struct Argument { int age; char name[50]; } ; and a method extern "C" { __declspec(dllexport) Argument FillData(Argument data) { Argument mydata; mydata.age=data.age; for(int i=0;i<=sizeof(data);i++) { mydata.name[i]=data.name[i]; } return mydata; } i declare it in c# in Cs_dll.cs [StructLayout(LayoutKind

Error when instantiating .NET/COM interop class via classic ASP

◇◆丶佛笑我妖孽 提交于 2019-11-29 16:55:28
I am having a problem when trying to instantiate a C# .NET class that's been exposed to COM in a classic ASP application. I've used tlbexp to generate a typelib and registered it in Component Services; now when trying to create the object as such: Server.CreateObject("The.Class.Name") I am getting the error: Server object error 'ASP 0177 : 80131534' Server.CreateObject Failed I've searched around online for information on this error, and found numerous discussions but no solution. The error code 0x80131534 apparently means "COR_E_TYPEINITIALIZATION, a type failed to initialize", which would

Setting up a DLL for registration-free COM Interop with C# / Managed code

ⅰ亾dé卋堺 提交于 2019-11-29 15:59:41
I am new to COM and have to create a COM wrapper for a C++ dll, to make some functionality in it accessible for managed code. I mainly followed this tutorial on code project to create a COM ATL dll. I created a post-build-step that calls tlbimp.exe on the COM dll to create the wrapping. Adding a reference to the dll that tlbimp.exe creates works, and I get code completion for methods on my COM dll, and can compile managed code that uses that dll. However, running that code leads to the following exception: Unhandled Exception: System.Runtime.InteropServices.COMException: Retrieving the COM

Access C variable in swift

岁酱吖の 提交于 2019-11-29 15:52:37
I'm trying to access a state variable declare in .h file but the compiler said the variable doesn't exist. Do I need to add anything in my bridging header file ? In my swift file I can't access dstate or cstate The compiler says "Use of unresolved identifier 'dstate'" on the line g722_coder_init(&dstate) . Header file #ifdef __cplusplus extern "C" { #endif extern struct g722_dstate dstate; extern struct g722_cstate cstate; int g722_coder_init ( struct g722_cstate *s ); int g722_encode(short *data, unsigned char *outdata,int len, struct g722_cstate *s ); int g722_decoder_init ( struct g722

Could not load type Microsoft.Office.Interop.Excel._Application

不问归期 提交于 2019-11-29 15:36:35
I'm getting a error when I try to debug a code that reads Excel files. I'm wondering if the reference to 'Microsoft.Office.Interop.Excel._Application' is wrong, I get the following error. isn't the Microsoft.Office.Interop.Excel version suppose to be 12? and not loaded from my project assembly? Could not load type 'Microsoft.Office.Interop.Excel._Application' from assembly 'Dialog, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The type is marked as eligible for type equivalence, but the containing assembly is not loaded as fully trusted. When I try to debug the code I get the

PInvoke error when marshalling struct with a string in it

你离开我真会死。 提交于 2019-11-29 15:30:15
I have a C++ struct struct UnmanagedStruct { char* s; // Other members }; and a C# struct struct ManagedStruct { [MarshalAs(UnmanagedType.LPStr)] string s; // Other members } the C++ library exposes extern "C" UnmanagedStruct __declspec(dllexport) foo( char* input ); And it is imported like [DllImport("SomeDLL.dll", CharSet = CharSet.Ansi)] static extern ManagedStruct foo( string input ); However when I call this function I get MarshalDirectiveException was unhandled Method's type signature is not PInvoke compatible. The thing is, this function call works if I remove the char* s and the string

How do I read the values of Excel dropdowns or checkboxes from c# or vb.net?

给你一囗甜甜゛ 提交于 2019-11-29 15:29:25
I'm using Microsoft.Office.Interop.Excel to read the values of cells of a worksheet, but I'm unable to find information that shows how to read dropdowns, checkboxes and option buttons. Thanks! Apparently accessing the DropDowns collection directly is verboten . A workaround is to access the Validation property of the cell containing the dropdown, get it's formula and then parse out the location of the list. Excel.Range dropDownCell = (Excel.Range)ws.get_Range("A1", "A1"); //cell containing dropdown string formulaRange = dropDownCell.Validation.Formula1; string[] splitFormulaRange =

Prevent JavaFX thread from dying with JFXPanel Swing interop?

无人久伴 提交于 2019-11-29 14:24:45
问题 I'm embedding several JFXPanels into a Swing app and the JavaFX thread dies when the JFXPanels are no longer visible. This is problematic because creating another JFXPanel after the JavaFX thread dies will not start another JavaFX thread and thus the JFXPanel will be blank. From what I can tell the JFXPanel ctor starts the JavaFX thread by calling: PlatformImpl.startup(new Runnable() { @Override public void run() { // No need to do anything here } }); Later on once the JFXPanel has a parent

Do I need to pin an anonymous delegate?

风流意气都作罢 提交于 2019-11-29 13:41:19
I am calling CopyFileEx from a C# application with an anonymous delegate being passed into the LPPROGRESS_ROUTINE parameter in order to get notifications on the file copy progress. My question is, does the anonymous delegate need to be pinned and why (or why not). In addition, does the answer change if: CopyFileEx was not blocking. If I passed in a delegate that was not anonymous. Thanks! The delegate does not need to be pinned . A managed object is pinned if it cannot be moved by the garbage collector. If the marshalling information is correct then the marshalling layer will ensure that a