Click here to Skip to main content
15,887,895 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C++
#using<mscorlib.dll>
using namespace System;
using namespace Interop.SpotOnCCD_USB2; // the required Dll which i have also referenced. 
using namespace std;
using namespace System::Runtime::InteropServices;
using namespace System::Diagnostics;
#include "stdafx.h"
ref class New
{
public:
/*error C2337,C2059,C2143*/[System.Runtime.InteropServices.DllImport("Interop.SpotOnCCD_USB2.dll")]
/*error C2653,C2238 */static void GetMatrix([MarshalAs(UnmanagedType::LPArray)] array<int>^ );
};
int main(array<System::String ^> ^args)
{
    
}



Hi! I am trying to create a CLR DLL which references a dll named "Interop.SpotOnCCD_USB2.dll". I am working with VS2008.

As far as i have checked and have used the same code in VS2010 without such errors. Please let me know what you think!!

my questions are dependent on the given code.I get the following list of errors:

error C2337: "System": Attribute not found .

error C2143: Syntaxerror: missing ']' before '.'

error C2059: Syntaxerror: '.'

error C2653: 'UnmanagedType':is not a class or namespace name

error C2238: unexpected token(s) preceding';'

Thanks in advance!!
Posted
Comments
lewax00 28-Aug-12 11:16am    
If you're using C++/CLI, why do you need to use P/Invoke, can't you just access it directly?
kash_sheetansh 28-Aug-12 11:22am    
its a com dll. I know i could easily access it directly for any other DLL but i cant.

1 solution

The first set of errors (maybe all of them) should be solved fairly easily: . is not used for namespaces in C++/CLI, :: is, so change
C#
[System.Runtime.InteropServices.DllImport("Interop.SpotOnCCD_USB2.dll")]

to
C
[System::Runtime::InteropServices::DllImport("Interop.SpotOnCCD_USB2.dll")]

or
C
[DllImport("Interop.SpotOnCCD_USB2.dll")]


Not sure if that will fix all of your errors, but it should clear up a few.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900