Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
#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 28-Aug-12 6:01am
Comments
lewax00 at 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 at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
[System.Runtime.InteropServices.DllImport("Interop.SpotOnCCD_USB2.dll")]
to
[System::Runtime::InteropServices::DllImport("Interop.SpotOnCCD_USB2.dll")]
or
[DllImport("Interop.SpotOnCCD_USB2.dll")]
 
Not sure if that will fix all of your errors, but it should clear up a few.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 525
1 Maciej Los 319
2 BillWoodruff 174
3 Suraj Sahoo | Coding Passion 170
4 /\jmot 152
0 OriginalGriff 8,654
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,229
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 28 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100