473,382 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Compiler error CS1518

Hi,

Because GDI+ doesnt support inversion of rectangles on a graphics device
(!!!) I'm attempting to call InvertRect() on the api direct from my c#
project.

In the file in questions, directly after the using directives and before
the class/namespace bit I've got (found this on the web):

[DllImport("user32.dll")]
[return:MarshalAs(UnmanagedType.Bool)]
public static bool InvertRect(IntPtr hDC, rf System.Drawing.Rectangle lprc);

The bool on the last line is generating the error. I'm using VS pro 2003.

Help!!
Jul 22 '05 #1
3 3889
>In the file in questions, directly after the using directives and before
the class/namespace bit I've got (found this on the web):

[DllImport("user32.dll")]
[return:MarshalAs(UnmanagedType.Bool)]
public static bool InvertRect(IntPtr hDC, rf System.Drawing.Rectangle lprc);

The bool on the last line is generating the error. I'm using VS pro 2003.

P/Invoke method declarations must be placed inside a type (class or
struct) just like any other method.

In addition to that, you must add the extern keyword to the
declaration, and change "rf" to "ref".

But even then it will not work as expected, because the internal
layout of a System.Drawing.Rectangle isn't the same as a GDI RECT
struct.


Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 22 '05 #2
Mattias Sjögren wrote:
In the file in questions, directly after the using directives and before
the class/namespace bit I've got (found this on the web):

[DllImport("user32.dll")]
[return:MarshalAs(UnmanagedType.Bool)]
public static bool InvertRect(IntPtr hDC, rf System.Drawing.Rectangle lprc);

The bool on the last line is generating the error. I'm using VS pro 2003.
P/Invoke method declarations must be placed inside a type (class or
struct) just like any other method.

In addition to that, you must add the extern keyword to the
declaration, and change "rf" to "ref".


That's a typo.

But even then it will not work as expected, because the internal
layout of a System.Drawing.Rectangle isn't the same as a GDI RECT
struct.


Any way to convert?
Jul 22 '05 #3
redeclare your own rectangle struct using a definition from www.pinvoke.net.
"Phil Da Lick!" <ph***********@NOSPAMhotmail.com> schrieb im Newsbeitrag
news:#P**************@TK2MSFTNGP10.phx.gbl...
Mattias Sjögren wrote:
In the file in questions, directly after the using directives and before
the class/namespace bit I've got (found this on the web):

[DllImport("user32.dll")]
[return:MarshalAs(UnmanagedType.Bool)]
public static bool InvertRect(IntPtr hDC, rf System.Drawing.Rectangle lprc);
The bool on the last line is generating the error. I'm using VS pro
2003.
P/Invoke method declarations must be placed inside a type (class or
struct) just like any other method.

In addition to that, you must add the extern keyword to the
declaration, and change "rf" to "ref".


That's a typo.

But even then it will not work as expected, because the internal
layout of a System.Drawing.Rectangle isn't the same as a GDI RECT
struct.


Any way to convert?

Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: rollasoc | last post by:
Hi, I seem to be getting a compiler error Internal Compiler Error (0xc0000005 at address 535DB439): likely culprit is 'BIND'. An internal error has occurred in the compiler. To work around...
1
by: Ayende Rahien | last post by:
reparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error (0xc0000005 at address 53168B12): likely culprit is 'BIND'. An internal...
1
by: Franko | last post by:
I get the following error. Please help c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,38): error CS1001: Identifier expected c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,52): error...
3
by: Mark Rockman | last post by:
------ Build started: Project: USDAver2, Configuration: Debug .NET ------ Preparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error...
4
by: David Sworder | last post by:
Consider the following line of code (it's not important what it does): resp.DocItem=Relations.SelectDocItems_BySearchString(req.SearchPhrase); It turns out that this line is in error. The...
1
by: Franko | last post by:
I get the following error. Please help c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,38): error CS1001: Identifier expected c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,52): error...
3
by: Phil Da Lick! | last post by:
Hi, Because GDI+ doesnt support inversion of rectangles on a graphics device (!!!) I'm attempting to call InvertRect() on the api direct from my c# project. In the file in questions, directly...
9
by: blackdog | last post by:
I compiled *.cs which contains public partial class xxx: System.Web.UI.Page I got errors as below: xxx_cs.aspx.cs: error CS1518: Expected class, delegate, enum, interface, or struck. Please...
27
by: Dave | last post by:
I'm having a hard time tying to build gcc 4.3.1 on Solaris using the GNU compilers. I then decided to try to use Sun's compiler. The Sun Studio 12 compiler reports the following code, which is in...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.