Menu
  • HOME
  • TAGS

Converting data from C++ dll in C#

c#,arrays,interop,pinvoke

Your problem is that you are returning the address of a local variable. As soon as the function returns, that local variable's life ends. And so the address you return is the address of an object whose life is over. The clean way to do this is to let the...

Exception HResult 0x800a03ec when trying to open Excel with Microsoft.Office.Interop.Excel.Workbooks.Open()

excel,wcf,windows-services,interop

The Exception was thrown upon opening the Document; on the machine which generated the Excels, the files were generated invalid. The solution was to change the Format of the numbers. Go into System Configuration -> Time, Language and Region -> Language Tap on the highlighted Hyperlink Open Advanced Settings Change...

Align text in Excel cell with new line c#

c#,excel,styles,interop,excel-interop

2 points to consider: Point 1 I have noticed that you want to change vertical alignment, but you use xlHalign. Please try changing that line to ws.Cells[j, i].Style.VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter; Point 2 Try removing Style. So you would have something like ws.Cells[j, i].VerticalAlignment = ... Let me know if it...

How to call constructor of Scala trait in Java subclass?

java,scala,inheritance,interop

That would become something like: public interface A { } public abstract class A$class { public static void $init$(A $this) { Predef..MODULE$.println((Object)"A"); } } using a decompiler. Java speaking, that is: public class AImpl implements A {} public class User { public User() { A a = new AImpl(); A$class.$init$(a);...

SerialPort check CTS

c#,winapi,serial-port,interop

You need to use GetCommModemStatus to retrieve status of CTS. You can use WaitCommEvent in non-blocking mode with overlapped IO. That is, opening the port as overlapped and providing the 3rd parameter of WaitCommEvent....

Excel.Range.set_Value causing “Exception from HRESULT: 0x800A03EC”

c#,wpf,excel,interop,spreadsheet

At the end I found that it was a problem length. I can't add a cell with more than 8192 chars. It's a limitation of Excel 2007. No problems with Excel 2010

Generate Oulook Email From Server

c#,asp.net,outlook,interop,openxml

I did find the Javascript code which seems do have similar functionality. I was hoping someone might have an OpenXML solution but this JS solution can work and is better than Outlook Interop var theApp //Reference to Outlook.Application var theMailItem //Outlook.mailItem //Attach Files to the email, Construct the Email including...

Excel file operations using interop in multithreaded C# application fails

c#,.net,multithreading,interop,export-to-excel

I believe the Excel object model is apartment threaded, so calls from your multiple threads will be marshaled to the same thread in the Excel process - which may be busy especially if there are several client threads. You can implement IMessageFilter (OLE message filter, not to be confused with...

Importing Microsoft.VisualStudio.Shell.Interop

vb.net,vba,import,interop

Importing the namespace is just like importing any other namespace. The actuall dll name is: Microsoft.VisualStudio.Shell.Interop which is part of an SDK that you may not have. If you don't have the SDK you will have to get it to get the dll to add as a reference to your...

Changing ChartData of a PowerPoint Chart with vb.net

vb.net,interop,powerpoint

I just found the answer by myself. First you have to activate the ChartData Object and second you have to refresh the datasource after importing the data to updata the sheet. Her is what works: _pptSld = _pptPre.Slides(2) _pptChar = _pptSld.Shapes(2).Chart _pptChartData = _pptChar.ChartData _pptChartData.Activate() oWorkBook = CType(_pptSld.Shapes(2).Chart.ChartData.Workbook, Excel.Workbook) oWorkSheet...

Conversion of const char** to std::vector

c#,c++,interop,type-conversion

You need to give the unmanaged code some way to obtain the length. There are two commonly used approaches: Pass the length of the array as an extra parameter. Use a null terminated array. The array ends when you encounter an item that is null. Either option is simple enough...

VC++/CLI: How to prevent an unmanaged object from being destroyed when it goes out of scope?

c++,.net,visual-c++,c++-cli,interop

You can either change getTheB to return a heap-allocated ClassB, or have ManagedClassB make his own copy of the db object. Update for the copy: I assume ManagedClassB's constructor looks something like public ref class ManagedClassB { public: ManagedClassB(ClassB* p) : m_p(p) { } ... private: ClassB* m_p; }; You...

C# string to Inno Setup

c#,interop,marshalling,inno-setup

The .NET String type definitely won't marshal to Pascal string type. The .NET does not know anything about Pascal types. The .NET can marshal strings to character arrays (and Pascal can marshal string from character arrays). But when the string is a return type of a function, there's problem with...

How to read list item of same list group?

interop,vsto,office-interop

Thanks to all for supporting, I found the answer of the question. foreach (Word.Paragraph firstItem in document.Content.ListParagraphs.OfType<Word.Paragraph>().Reverse()) { if (firstItem.Range.ListFormat.List != null) { foreach (Word.Paragraph item in firstItem.Range.ListFormat.List.ListParagraphs) { } } } ...

Run Java computation engine from .Net

java,vb.net,interop

What comes to mind would be to wrap your Java engine behind a web end point. This endpoint, such as a REST web service, or something similar will allow other applications to communicate with your Java engine without them caring how is the engine itself implemented. This would also allow...

C++ and java , SQLITE server acces same Time

java,c++,sqlite,interop,server

You can write the server in whichever language you wish as long as you send and receive messages over sockets, as bytes, which aren't language specific and easy to implement. This way you can also do an easy switch to a distributed application. If the server and the clients are...

Pass structure (or class) from C++ dll to C# (Unity 3D)

c#,c++,dll,plugins,interop

It should work correctly (at least, here in a small C++ + C# project I have, I was able to make it work with that struct, both in x86 and x64) [DllImport("MyWrapper.dll", CallingConvention = CallingConvention.Cdecl)] private static extern HandInfo MyWrapper_getLeftHand(); The only thing, you must declare the CallingConvention = CallingConvention.Cdecl....

BizTalk and COM+

.net,interop,biztalk,com+

No, not out of the box. You can write a custom Adapter than wraps the COM+ comp and submits messages to you BizTalk app. However, your current plan is more than serviceable so I would stick with that....

Propagating errors from C# dll

c#,dll,interop

If you need cross-boundary solution, use one suggested by Microsoft: IErrorInfo interface. Implement IErrorInfo in the DLL and wrap all exporting function into try-catch: try { Something; return someDataType; } catch(SomeException e) { SetErrorInfo(0, new MyErrorInfo(e.Message)); return null; } [DllImport("oleaut32.dll")] extern static int SetErrorInfo(uint dwReserved, IntPtr pErrorInfo); In the application...

Get pages of word document

c#,.net,ms-word,interop

Eventually, I finished up with this, and it works (it's lame, it's ugly, but it does what it should): public string[] GetPagesDoc(object Path) { List<string> Pages = new List<string>(); // Get application object Microsoft.Office.Interop.Word.Application WordApplication = new Microsoft.Office.Interop.Word.Application(); // Get document object object Miss = System.Reflection.Missing.Value; object ReadOnly = false;...

Unable to assign formula to cell range in Excel

vb.net,excel,excel-formula,interop,excel-2010

The error might be coming from your current data, respectively, the layout of the sheet. I would suggest you to check what is inside the listO.Range(i, j).FormulaR1C1 before you assign the formula. I have had a case where the range has already got wrong data inside, and then strangely, I...

The type 'System.Runtime.InteropServices.SafeHandle' exists in both 'System.Runtime.InteropServices.dll' and 'System.Runtime.Handles.dll'

c#,dll,reference,compiler-errors,interop

I finally found a solution for my problem. It wasn't easy to find but I did it! Since my solution is very specific to my project, I'll post the steps I used to solve it. I hope it can help someone! I unloaded my startup project and created a new...

Platform::Array^ to char* - conversion and memory

arrays,interop,c++-cx

So, to answer my first question - Converting Platform::Array to char* was nothing harder than: const char* data = _strdup((const char*)data->Data); Note, I am using Visual C++ CLI (Visual Studio 2013), so the _strdup is the choice there. As for the pinning - will see later :)...

Calling C# function from a C++/CLI function

c#,c++,c++-cli,interop,marshalling

Maybe this example can help you: Write a Managed DLL To create a simple managed DLL that has a public method to add two numbers and return the result, follow these steps: Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005. On the File menu, point to New, and...

Interop service does not work with NuGet WatiN

c#,.net,interop,nuget,watin

In the end it was rather simple - I just had to build the solution and copy the DLL from the folder to the project.

How to enforce generic type with Kotlin interop

java,generics,interop,kotlin

I can see two options: The first is to return an Observable<MutableList<FooBar>>. As a List is immutable in kotlin, it is declared as List<out T> since objects of type T can only be taken out of it. MutableList on the other hand is Java's true List equivalent: since it is...

Hiding a member from .NET code but not from COM

.net,interop,com-interop

No, members must be public to be usable from a COM server. It is a fairly simple workaround, the COM client only ever sees the interface, the .NET programmer sees the class. So you can expose the DateTime method in the interface and implement it explicitly in the class so...

Create Outlook meeting on SharePoint page

sharepoint,sharepoint-2010,outlook,interop,meeting-request

The Considerations for server-side Automation of Office article states the following: Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office...

Convert C# string to C++ WCHAR* over COM

c#,c++,string,com,interop

It looks like there are at least two solutions to this problem. Add the string attribute to the parameter in the IDL to treat the pointer as a string, so this: HRESULT Foo([in] const WCHAR* bar); becomes this: HRESULT Foo([in, string] const WCHAR* bar); Then, a string can be passed...

Calling overloaded scala case apply from java using java generic

java,scala,generics,interop

There are two problems in your code: Java generics are erased at runtime, so in order to do something like T.apply, you'd need an instance of the T, so your method would look like: public <T> Option<T> getResult(String name, T t) You need an upper bound where the apply method...

image (noninlineshape) from Word to clipboard to file

c#,image,ms-word,interop,clipboard

OK, the problem seems to have been that I tried to convert it at the wrong time. If I loop through all Shapes and convert them before trying to do anything else it works fine. int number = doc.InlineShapes.Count; MessageBox.Show(number.ToString()); // 0 to begin with foreach (Microsoft.Office.Interop.Word.Shape s in doc.Shapes)...

Late Binding and WithEvents using VBA

c#,vba,com,interop

Private WithEvents Processor... The WithEvents statement instructs to discover value events and connect them to the available code handlers. When you initialize Processor value, you will have the following actions taking place behind the scene: checking COM server class information, identification of events interface available, discovering connection point container, connecting...

Pinvoke Bool - MarshalDirectiveExeption

c#,c++,interop,pinvoke

As the error says, the struct is not p/invoke compatible. Function return values must be blittable and that type is not. The information can be found here: http://msdn.microsoft.com/en-us/library/75dwhxf7.aspx Structures that are returned from platform invoke calls must be blittable types. Platform invoke does not support non-blittable structures as return types....

C# Decimal to VB6 Currency

c#,vb6,interop,decimal,currency

After some reading I came up with this solution (see also under Update 2). I had to marshal the Decimal type in .Net to the Currency type in the unmanaged VB6 code and vice versa. [return: MarshalAs(UnmanagedType.Currency)] public decimal GetDecimalFromNetDll() { decimal value = ... // Read from database return...

PInvoke with a void * versus a struct with an IntPtr

c#,interop,pinvoke

If your StructLayout is Sequential, then it is indeed identical. Easiest way to verify this for yourself is to try it out, of course: Make a C++ Win32 DLL project: extern "C" { __declspec(dllexport) void MyFunction(const void* ptr) { // put a breakpoint and inspect } } Make a C#...

how to add/import objective-c files to a swift app

objective-c,swift,interop,xcode6

Google swift bridging header. See the first result. I need 21 more characters.

C++-Python Interop: Marshalling data faster

python,c++,interop,python-c-api

Before Py_BuildValue can build the tuple you want, it needs to parse the format string you give it to determine the type and number of its arguments as well as what the returned PyObject will be. If you know all this ahead of time, you can skip these steps and...

Microsoft Interop OutLook C#- Cannot save attachments of type OLE

c#,outlook,interop,office-interop,com-interop

You would need to call IAttach::OpenProperty(PR_ATTACH_DATA_OBJ, IID_IStorage, ...) then open a particular stream from IStorage that contains the data that you are after. Note that the stream and its format are specific to the application that created the OLE attachment. Redemption supports Word Pad, Paint Brush, Excel, Power Point, Word,...

Unload addin .xla when uninstall Excel interop add-in

excel,interop,action,add-in,uninstall

Don't use Addins.Add - just have A open the XLA as if it was a workbook. Then when Excel closes the XLA will close and you don't need to mess with the Addins manager.

Writing to a floating point OpenGL texture in CUDA via a surface

c++,opengl,cuda,interop,textures

It turns out the answer was pretty simple, though I don't know why it works. Instead of calling surf2Dwrite<float4>(sample, tex, (int)sizeof(float4)*x, y, cudaBoundaryModeClamp); I needed to call surf2Dwrite(sample, tex, (int)sizeof(float4)*x, y, cudaBoundaryModeClamp); To be honest I'm not sure I fully understand CUDA's use of templating in c++. Anyone have an...

If there's a value in the specified column, highlight row

c#,excel,interop

I solved the problem, here is the end result public void HightlightErrors() { Worksheet worksheet = (Worksheet)workbook.Sheets[1]; Range last = worksheet.Cells.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeLastCell, Type.Missing); Range myRange = worksheet.get_Range("A1", last); int lastUsedRow = last.Row; int lastUsedColumn = last.Column; for (int i = 1; i < lastUsedColumn; i++) //Check each column to see if...

Immediate Access Violation when debugging Windows.Devices.Sensors project in Windows 7

c++-cli,interop

The fix is to Delay Load the managed DLL. The allows the application to run until that DLL is explicitly called. Thanks to Ben Voight for his answer here: http://stackoverflow.com/a/28467701/1454861

Using Microsoft.Office.Interop.Outlook without Outlook Client installed

c#,outlook,interop,office-interop

It is not possible to use the Interop assemblies without its associated application installed where you need to use it. The Interop assemblies are used primarily as an advanced application automation system. If you are using Exchange Server 2007 or later, you could consider using the technique described in this...

How to export datagridview into Open Office Excel c#

c#,datagridview,interop,.net-assembly,openoffice.org

You need to add references for following assembles: cli_basetype, cli_cppihelper, cli_oootypes, cli_ure, cli_uretypes And also using unoidl.com.sun.star.lang; using unoidl.com.sun.star.bridge; using unoidl.com.sun.star.frame; using unoidl.com.sun.star.beans; using UNO = unoidl.com.sun.star.uno; using OOo = unoidl.com.sun.star; using unoidl.com.sun.star.text; using unoidl.com.sun.star.container; using unoidl.com.sun.star.sheet; using unoidl.com.sun.star.table; And also example how to get a worksheet: UNO.XComponentContext context =...

How to get CustomDocumentProperties using Excel Interop?

c#,excel,interop,vsto

I noticed that Microsoft.Office.Interop.Excel.Application is an interface, so using new on interface is actually strange to me. That is strange indeed, but by design. The Excel.Application interface is decorated with the CoClass attribute telling the actual class to instantiate on 'instantiating' the interface. More about it here. But when...

How does Spark interoperate with CPython

scala,pandas,apache-spark,interop,pyspark

PySpark architecture is described here https://cwiki.apache.org/confluence/display/SPARK/PySpark+Internals. As @Holden said Spark uses py4j to access Java objects in JVM from the python. But this is only one case - when driver program is written in python (left part of diagram there) The other case (the right part of the diagram) -...

c# WM_TOUCH Messages in WndProc and PreFilterMessage

c#,winforms,interop,wndproc,wm-touch

I ended up using a different approach since i could not get this to work. I used a transparent form as an overlay (like this) to get the correct Message. This way I got the right LParam. Also I could forward the Message to the window below the overlay by...

Why does my C++ interop works on .Net 4.5 but not on 4

c#,.net,windows,dll,interop

BadImageFormatException is most likely a result of trying to load an executable having the wrong "bitness" (e.g. loading a 32 bit DLL in a 64 bit process). If Legacy.dll is a 32 bit DLL (which it seems to be based on the information you have provided) you should simply compile...

Call native method from Swift that has uint8_t ** as output parameter

swift,pointers,interop,pointer-to-pointer

Assuming that foo() allocates an uint8_t array, puts the address into the memory location pointed to by output, and returns the size of the allocated array, you can use it from Swift like this var output : UnsafeMutablePointer<UInt8> = nil let size = foo(&output) for i in 0 ..< size...

Casting Range.Value2 of Excel interop to string

c#,excel,interop

I found the solution which may be not so nice but works: myString = range.Value2 == null ? "" : range.Value2.ToString(); May be something better exists....

Swift class “does not implement (objc) protocol”

objective-c,swift,interop,protocols

In Swift 1.2 (Xcode 6.3.2) NSSet is mapped to Set<NSObject>, so you would have to define the property as @NSManaged var friends: Set<NSObject> to satisfy the protocol. In Swift 2 you can define the Objective-C protocol method using "lightweight generics"....

How to handle C++ Native Callback Class in managed wrapper

.net,delegates,c++-cli,interop,function-pointers

I have now a solution, which seems to be working correctly: First, I'm defining a native proxy class for holding the callbacks: public class CbProxy : Callback { public: NATIVE_CALLBACK _cbHandler; virtual void Handler() { if(_cbHandler != NULL) _cbHandler(); } } Now I can attach the managed delegate to the...

How to wrap a C __cdecl API so that FORTRAN can call it (using __stdcall)?

c++,c,interop,fortran,wrapper

The linker can't link your FORTRAN code to the library because the function name is mangled ( C++ thinks the function is named [email protected]@[email protected], FORTRAN is expecting it to be named wrapper_sub) Write your wrapper in C, not C++, or add an extern "C" to fix the problem. extern "C"...

When passing null to Interop method it throws “Generic types cannot be marshaled.” exception

c#,generics,interop

I am guessing that you have mistaken Nullable<byte> as being equivalent to C++'s unsigned char * or similar. It's not. It is literally a single byte, but where the value can also be null. As the error message says, you also are not permitted to pass generic types, and of...

How VB6 host .net 2.0

c#,vb.net,interop,clr,com-interop

I found the answer finally. I posted it here since maybe it is usefule for someone else. You can refere mscorlib.tlb in excel VBA, then: Dim ap as ApplicationDomain, apm As mscorlib.AppDomainManager, result as object Set apm = New mscorlib.AppDomainManager Set m_domain = apm.CreateDomain("kissingerDomain", Nothing, Nothing) set object = m_domain.CreateInstanceFrom(DLL_Path,...

C# Native Interop - Why most libraries use LoadLibrary and delegates instead of SetDllDirectory and simple DllImport

c#,.net,interop,pinvoke

Hmya, blog posts, that fundamentally flawed way to distribute technical information. The world would be a better place if we could vote for them. The author is comparing apples and oranges. Well, more like apples and bicycles. There are two fundamentally different kind of interop scenarios being compared here. The...

Outlook Interop ClearSelection Method

c#,wpf,outlook,interop

Do you handle the Drag event in your application? If so, try to call the following code in the event handler: e.Data.GetData(“RenPrivateMessages”); See Outlook, custom task pane and drag-drop problem for more information. ...

Print lists in a list to excel, randomly stops printing after 0.5-6 lists. Comexpection 0x800AC472

c#,string,excel,list,interop

Here is my reflection code. public static DataTable ClassToDataTable<T>() where T : class { Type classType = typeof(T); List<PropertyInfo> propertyList = classType.GetProperties().ToList(); if (propertyList.Count < 1) { return new DataTable(); } string className = classType.UnderlyingSystemType.Name; DataTable result = new DataTable(className); foreach (PropertyInfo property in propertyList) { DataColumn col = new...

CUDA with OpenGL: all CUDA-capable devices are busy or unavailable

c++,opengl,cuda,interop

Given that the interop does not work for examples provided with the CUDA installation (can be found in ProgramData/Nvidia Corporation/Examples), the problem is not the code, but rather the computer's configuration. I did, for good measure, first unistall all of my old CUDA versions and reinstalled CUDA 7.0. That didn't...

Converting a C char array to a String

arrays,swift,interop,tuples

You can get a pointer to the tuple with withUnsafePointer(&record.name) { ... } (this requires record to be a variable). The pointer can then be converted to anUnsafePointer<Int8> and used in String.fromCString(): var record = someFunctionReturningAStructRecord() let name = withUnsafePointer(&record.name) { String.fromCString(UnsafePointer($0))! } This assumes that the bytes in name[] are...

Can I use C++ dll through Interop to offload to Xeon Phi?

c#,.net,interop,xeon-phi,intel-parallel-studio

There are DLLs, which can perform automatic offload to Intel Xeon Phi, e.g. Intel MKL. These libraries can be linked with either C++ and C# (see froth's answer). Automatic offload in this context means that a library contains a code, which allows to offload its computations, transparent to the user....

Calling Python from .NET via C++ bridge

c#,python,c++,.net,interop

I have used it once in following way:- There was a C# dll from which I need to query for data. So, I developed C++/CLI module to interact with that dll and handled some delegates and events corresponding to that data. Then C++ module would accept this data, process it...

what is the easiest way to pass a list of integers from java to a frege function?

java,list,interop,frege

You could use a good old int [] array, the corresponding frege type would be JArray Int. Because arrays can be made from and into lists in both Java and frege, they are good for such tasks. Please use the repl to get an idea how to convert the array...

C# COM-Interop dll for C++ COM dll doesn't work between 2 solutions

c#,c++,.net,com,interop

The located assembly's manifest definition does not match the assembly reference. Very common exception message, the DLL it finds at runtime isn't the same as the reference assembly your program was compiled with. A very basic DLL Hell problem, not otherwise specific to COM interop. You diagnose these kind...

Need help resolving AccessViolationException with C#/C interop

c#,interop,libmosquitto

I ended up creating a C++/CLI project to wrap the C project to .NET. I found it much easier to manage the unmanaged code using C++, and I ended up with a nice interop to C# as my class became .NET accessible. I would recommend this path, and will do...

Why does the storage size of a char seem to change?

c#,struct,char,interop,marshalling

Because you are are marshaling, and by default, a char will get marshalled to an ANSI char instead of a Unicode char. So "balloon" is 8 characters, which is 8 bytes when ANSI encoded, plus 4 bytes for your int, which is 12. If you want the size to be...

Is this an ok way of calling a C++ function from C#?

c#,c++,interop,clr

As the comment of xanatos already suggested, your native function/method is not really native as some parameter are still C++/CLI. If you want to wrap to native C++, I suggest (as I did it myself before): void ClassProxy::myMethod(int val1, int val2, array<int>^ in, array<int>^ output) { std::vector vin; pin_ptr<in> pin(&in[0]);...

ShellExecute doesnt work if some parameters are just int type

c#,windows,shell,interop

You need to dig into the Windows SDK headers to see how large the type is. For example, for a 64 bit process, sizeof(HWND) is 8 in C++ and sizeof(int) is 4 in C# therefore if you use int to store HWND, you are corrupting memory. Same for HKEY, LPITEMIDLIST,...

Add hyperlink to a slide in the current PowerPoint

c#,interop,powerpoint

Finally I've figured it out, and since there's lack of resources, I would like to post my solution. Interestingly, to add a hyperlink to a slide inside the same presentation, you need to leave Address property blank, and set its SubAddress to be a string in a format: "yourSlideID,yourSlideIndex,yourSlideName". For...

Is there a C# ready-to-use class that imports everything from USER32.DLL? [closed]

c#,windows,winapi,interop,user32

There is no built in class or static library to do that. However, you could try a google search for some free libraries, or even write your own implementation. The thing is, user32.dll is part of the win32 api, which was originally meant for C++ applications. When Microsoft rolled out...

Method to Force C++ Class to be Destructed After Interop Call from C#

c#,c++,dll,interop,destructor

Never ever ever use new with free() or malloc() with delete because that's the road to programming hell. Therefore, since you allocated your object with new you should free it with delete. Using free() doesn't call the object's destructor (nor does malloc() call its constructor). The only time you'd need...

Need Clarification On Answer For Cleaning Up Excel Interop Objects Properly

.net,excel,interop,com-interop

I was in the habit of releasing objects as soon as I was done with them to minimize memory usage while the macro ran. Should I be concerned with cleaning up objects as I go or is it ok to just do a cleanup at the end of the...

Wrapping a GDI based MFC View for use in C# .Net managed code

.net,wpf,mfc,c++-cli,interop

Yes, we do exactly this in our application. We settled on creating a DIB memory block and selecting that into the DC before drawing and getting the bits into the WPF window by having an InteropBitmap in a main Grid control. You can also use a WriteableBitmap and Lock +...

Creating Some(object) from Java

scala,interop

Are you quite sure your method takes an Option[Activity]? Because that message suggests it's taking an Option[Class[_ <: Activity]]. Please post the Scala code and how you're calling it.

SetupDiGetDeviceRegistryProperty fails with ERROR_INVALID_DATA

c#,winapi,interop

Looks like what I'm looking for is impossible: There is not a supported way to figour out the IDs that you referred to programmatically. It was never a design goal to provide a way for applications to label monitors with the same IDs that the screen resolution control panel uses...

C#: Cdecl DllExport with a pointer to class instance in the arguments

c#,c++,interop

When I had to use PInvoke and had the need to pass instances of classes around as pointers, I wrote a simple wrapper for the unmanaged code that I would be using in C++ that only accepted primitive types and arranged them into whatever types were needed. When it came...

Interop Outlook - Sending Appointment from another mailbox

c#,email,outlook,interop,appointment

It is not clear whether you have got two accounts set up in the single Mail profile or separate profiles. The SendUsingAccount property of the AppointmentItem class allows to set an Account object that represents the account under which the AppointmentItem is to be sent. So, The SendUsingAccount property can...

Where can I find Microsoft.Office.Interop.Word.dll (2010)?

c#,.net,dll,interop,ms-office

You shouldn't be searching for the dll on your local system yourself if you installed the assemblies correctly. See following link for information on how to download and install office interop libraries without installing office. Second link details how to add the assemblies to your project correctly. Install Office Primary...

Releasing Com Objects

c#,excel,com,interop

do the following also : Worksheets sheets = excelApp.Worksheets; Marshal.ReleaseComObject(squidSheet); Marshal.ReleaseComObject(squidBook ); Marshal.ReleaseComObject(sheets); squidSheet = null; squidBook = null; sheets = null; GC.Collect(); GC.WaitForPendingFinalizers(); You have to release the sheets because you are holding a reference to it by doing this statement : squidSheet = squidBook.Sheets["Filenames"]; ...

Debugging a .NET COM DLL loaded by unmanaged C++ binary in Visual Studio

c++,.net,visual-studio-2010,com,interop

Yes, you have to enable managed debugging. One problem with Visual Studio (at least 2008 and 2010 -- don't know about later versions) is that you can only debug Native and Managed code at the same time with 32-bit processes. With 64-bit processes, you have to debug one type or...

C++/CLI String^ to char* 'error: cannot obtain value'

c++-cli,interop,wrapper,command-line-interface

There was no issue with conversion itself. The full signature of function was: Native::Foo(char* param1, short param2, char* param3, char* param4) { // param3 error: cannot obtain value char* } Here error appeared on 'param3'. Changing params order solved my problem: Native::Foo(char* param1, char* param3, char* param4, short param2) {...

How to make a Swift String enum available in Objective-C?

objective-c,swift,enums,interop

From the Xcode 6.3 release notes (emphasis added): Swift Language Enhancements ... Swift enums can now be exported to Objective-C using the @objc attribute. @objc enums must declare an integer raw type, and cannot be generic or use associated values. Because Objective-C enums are not namespaced, enum cases are imported...

Clojure interop with Java: how to call a class?

java,maven,clojure,interop,leiningen

You probably want to change the last period in your :import statement into a space: (ns mynamespace (:import [com.ollio.nlp Transformer])) (EDIT: You can't use wildcards here. Every class that in com.ollio.nlp must be listed explicitly, separated by spaces.) That will allow you to use Transformer unqualified: (.transform (Transformer. <add constructor...

Unable to get the Object property of the OLEObject class - Excel Interop

c#,excel,interop,office-2013

The solution is to delete all the .exd files from your %APPDATA% and %TEMP% because... This issue occurs because some scriptable controls are made obsolete in Office 2013 for security reasons. This is by design, and these errors are expected. These scriptable controls are disabled by using a version-specific kill-bit...

Method with return value as boolean

c#,interop,user32

As long as ShellExecuteEx signature is not bool? ShellExecuteEx(), you shouldn't be scared that it will return null because bool is a value type with a default false. Simply - a method with signature bool ShellExecuteEx() cannot return null cause it wouldn't even compile....

How to provide a Java-friendly interface for my Scala code?

java,scala,interop,standard-library

I'd have this Scala code: javaf(b: ArrayList[Pair[String, Int]) = scalaf(b.map(p => (p.getLeft, p.getRight)) Then Java people would call javaf whereas Scala people would call scalaf (in a separate place). That is exactly how Play writes some code in Scala and provides Java-friendly API using it. See for example the JavaResults...

Hosting WPF in separate C++ thread

wpf,multithreading,c++-cli,interop

The challenge you are having is writing to dependency properties directly. Those can only be done on same thread as the Window they are in. WPF works better by having its dependency properties read values via bindings - that avoids a lot of the threading issues. What you want is...

Outlook opens the task in a modal window after I opened this task in a modal window from the application

c#,outlook,interop

Try closing and Wait for let it be clear in finally statement. email.Close(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); ...

Interop between C++ classes inside an WinRT component

c#,c++,dll,windows-runtime,interop

Okay, I got it... very simple indeed, just use the internal keyword! I tried to solve this with this keyword before, but only on class level which was not possible because its a native c++ class. Anyway, when you use internal to members everything is okay: internal: list<Line>* getRenderPoints(); Now...

C# application won't run on other machines

c#,wpf,interop

So it turned out to be a missing dll being thrown in the InitializeComponent for whatever reason. My application has a c++ library we made that uses visual c++ 2012 dlls and the application was looking for the debug version of it instead of the regular one included in the...

Can I call a static method of a C# class from VBA via COM?

c#,.net,vba,com,interop

COM does not support static methods, and instances of COM objects do not invoke static methods. Instead, set ComVisible(false) on your static method, then make an instance method to wrap it: [ComVisible(true)] public class Foo { [ComVisible(false)] public static void Bar() {} public void BarInst() { Bar(); } } Or...