Problems with C # in referencing plugins | Csharp cite the plugin problem

Source: Internet
Author: User

Background: Use C # to manipulate the mouse for repetitive work

Background:using Csharp to handle the keyboard or mouse to doing the repetitive work.

Problem: The property "DllImport" is not valid in this claim type. It is only valid in the "method" declaration. Error 1 Property "DllImport" in the Declaration class

Question:attribution "DllImport" is invalid in the declaration, it's just valid in the "method" declaration

Solution: Use an externally invoked method

Solution:use the External method

code example:

private static extern int Mouse_event (
int dwflags,//One of the flags in the following table or a combination of them
int DX,
int dy,//specify absolute position or relative position in X, y direction
int cbuttons,//not used
int dwextrainfo//not used
);

extern is used to declare the method implemented externally, it's often used in the situation of that interop (using System. Runtime.interopservices) to call unmanaged code in and DllImport are used at the same time. At that time the method should declard as static.

Problems with C # in referencing plugins | Csharp cite the plugin problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.