Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
E

econner

@econner
About
Posts
202
Topics
99
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Any book recomendations on Telerik?
    E econner

    http://www.amazon.com/Pro-Telerik-ASP-NET-Silverlight-Controls/dp/1430229403/ref=sr_1_2?s=books&ie=UTF8&qid=1324413468&sr=1-2[^]

    The Lounge csharp wpf question announcement learning

  • Load ASP.Net controls from text file / database
    E econner

    Found it. c.ParseControl()

    ASP.NET tutorial question csharp asp-net database

  • Load ASP.Net controls from text file / database
    E econner

    I am working on trying to load some control code that is saved in a text file. The code is constructed of ASP.Net controls but could consist of any type of control from PlaceHolder, LliteralControl, TextBox, etc. How can I load this into a control located on the page? for example, I could pull this from a file or database. Control c = new Control(); //How to get raw text to control and add control to page??? c.???? Page.Controls.Add(c);

    ASP.NET tutorial question csharp asp-net database

  • Override Page.Theme directory
    E econner

    Is it possible to override the default path of /App_Themes for the Page.Theme location? I want to have themes available for different clients and have a directory like /App_Themes/{ClientName}/ Thanks

    ASP.NET question

  • Tablet recommendation?
    E econner

    I wanted a tablet but wanted to be able to run my existing software and RDP into servers, etc. I purchase the Acer Iconia W500[^] with Windows 7. As mentioned before, the Windows 7 is not the "best" tablet interface but is not limited to using applications written in the iOs or Droid languages. Also, the virtual keyboard is easy to use. With the docking station, I can use it as a 10" netbook with 4.5 hour battery life.

    The Lounge php ios mobile com question

  • RegEx with < or >
    E econner

    Thanks for the assistance and thanks for the link to Expresso.

    C# question regex tutorial workspace

  • RegEx with < or >
    E econner

    Basically, I have a field that either can take an integer value up to 3 digits or a decimal value with up to 2 decimal places. I change the mask in code before the screen is displayed. Below is an example of the existing masks. TextBox1.Mask ='\d?\d?\d?'; OR TextBox1.Mask = '\d+.\d?\d?'; Now, I need to have the integer mask have the ability to accept a <, > or N/A as well as to have the decimal mask do the same. I need it in two masks because I dont want certain fields to be able to enter decimal values and other fields to have the ability. I also can set the textbox to foce upper case for (N/A) and set a max length if needed.

    C# question regex tutorial workspace

  • RegEx with < or >
    E econner

    Thanks everyone for the suggestions. They have helped get started but the criteria has changed. I now need to support the following conditions: 1. a value of N/A only in the field => N/A 2. a numeric value with decimal points => 24.231 3. a numeric value that can begin with < character => < 12.1, or < .5 4. a numeric value that can begin with > character => > 27.2, or > .5

    C# question regex tutorial workspace

  • RegEx with < or >
    E econner

    Hello, I am trying to setup a RegEx expresion to check a text box for numeric values but also have the possibility to have a < or > symbol. For example the input could be 25.1 or > 20 or < 50, etc. How can I allow for the < or > symbol? Thanks

    C# question regex tutorial workspace

  • iPad to WCF Services authentication
    E econner

    I am currently working on a project that has an iPad application that uses JSON to call WCF services hosted with IIS. One of the requirements is that the WCF services needs to use IIS Basic Authentication to login. Once the user has been authenticated from the database, a few values need to set to a cookie for return trips to other WCF functions (similar to asp.net session variables). Is this possible with WCF and using cookies to hold state? If not, any recommended method? Thank you.

    WCF and WF csharp asp-net ios database wcf

  • Calling C++ Image API from C#
    E econner

    Erik, I wanted to thank you again for the assistance. I was able to confirm that the code require the buffer and pinning/marshaling of the memory and it will not work correctly without the suggestions you provided. I also wanted to let you know what compounded the testing issue with the error was due to incomplete documentation. After getting the process to work, I was able to change certain settings and was able to cause the process to fail. Basically, the image class has to define the height and width to the MAXIMUM allowed image that the scanner can accept. Then the buffer size is set to the max height * max width * single/double scanner mode. Once the scanner returns the image, it adjusts the height and buffer values to be what are read in from the scanner. If the image sizes are specified incorrectly/too small, the API will cause a memory error. For example, the image of the scanned area may be 4" but the scanner's read head is capable of scanning a wider area. So the image width has to be pre-set the maximum width of the read head and not the width of the item that is being scanned. BTW, these maximum values are not specified in the documentation or samples. I actually had to dig thru a C++ sample application and the header files to find these settings. Thanks again.

    C# csharp c++ data-structures json performance

  • Calling C++ Image API from C#
    E econner

    One of the functions was not in the documentation and the sample I was using. I found the function when reviewing the header file and the C++ test app code.

    C# csharp c++ data-structures json performance

  • Calling C++ Image API from C#
    E econner

    Erik - Thanks for your help. I have it working now. The reason it was failing after the last step was due to other settings that had to be set on the scanner. The vendor makes a single side and double side scanner. The sample in the documetation does not match the process. I dug around in the C++ sample and found other settings that I was able to specify before scanning the card.

    C# csharp c++ data-structures json performance

  • Calling C++ Image API from C#
    E econner

    Ok, below are the changes I tried. However, I am receiving an error of: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

    [DllImport("scandll.dll")]
    private extern static int WScanSelectBuf(MY_IMAGE image_down, MY_IMAGE image_up, int select);

    public static int ScanSelectBuf(MY_IMAGE image_down, MY_IMAGE image_up, int select)
    {
    return WScanSelectBuf(image_down, image_up, select);
    }

    int nWidth = 100;
    int nHeight = 200;

    img1.width = nWidth;
    img1.height = nHeight;
    img1.info = 8; // 8bit

    img2.width = nWidth;
    img2.height = nHeight;
    img2.info = 8; // 8bit

    byte[] buffer1 = new byte[2 * img1.width * img1.height];
    byte[] buffer2 = new byte[2 * img2.width * img2.height];

    // Pin these two arrays in the managed heap
    GCHandle bufferHandle1 = GCHandle.Alloc(buffer1, GCHandleType.Pinned);
    GCHandle bufferHandle2 = GCHandle.Alloc(buffer2, GCHandleType.Pinned);

    // Set the address of the buffers to each pbuf field
    //img1.pbuf = bufferHandle1.AddrOfPinnedObject();
    //img2.pbuf = bufferHandle2.AddrOfPinnedObject();

    img1.pbuf = Marshal.UnsafeAddrOfPinnedArrayElement(buffer1, 0);
    img2.pbuf = Marshal.UnsafeAddrOfPinnedArrayElement(buffer2, 0);

    // And now we can make the P/Invoke call
    ret = ScanSelectBuf(img1, img2, 0);

    // Do not forget to free the handles
    bufferHandle1.Free();
    bufferHandle2.Free();

    C# csharp c++ data-structures json performance

  • Calling C++ Image API from C#
    E econner

    I modified the code as per above. The img1.pbuf and img2.pbuf are now showing an address. However, the native API funtion of WScanSelectBuf(img1, img2, select) is still crashing. I have tried passing in:

    WScanSelectBuf(img1, img2, select) (MY_IMAGE)
    WScanSelectBuf(ref img1, ref img2, select) (ref of MY_IMAGE)
    WScanSelectBuf(img1, img2, select) (IntPtr)

    and changed the code in the DLLImport and wrapper method without any success. Is there anything I am missing with Marshaling, etc? I am coming to the conclusion that it could be an issue with the 3rd party's API libary and is doing something odd with the function. However, it does work in their C++ sample. I have contacted the vendor and they are not familar with .NET. However, they are reviewing this thread and for any suggestions.

    C# csharp c++ data-structures json performance

  • Calling C++ Image API from C#
    E econner

    I have modified the code as per my understanding of GCHandle. I am still getting memory errors. I believe it has something to do with the IntPtr of the pbuf in the MY_IMAGE struct. Here is my code so far:

    [StructLayout(LayoutKind.Sequential)]
    public class MY_IMAGE
    {
    public int width;
    public int height;
    public int info;
    public IntPtr pbuf; // image buffer
    }

    [DllImport("scandll.dll")]
    private extern static int WScanSelectBuf(IntPtr image_down, IntPtr image_up, int select);

    public static int ScanSelectBuf(MY_IMAGE image_down, MY_IMAGE image_up, int select)
    {

    GCHandle image\_downHandle = GCHandle.Alloc(image\_down, GCHandleType.Pinned);
    GCHandle image\_upHandle = GCHandle.Alloc(image\_up, GCHandleType.Pinned);
    
    int ret = WScanSelectBuf(image\_downHandle.AddrOfPinnedObject(),
                                  image\_upHandle.AddrOfPinnedObject(), select);
    

    //CRASHES HERE WITH ERROR:
    //Attempted to read or write protected memory.
    //This is often an indication that other memory is corrupt.

    image\_downHandle.Free();
    image\_upHandle.Free();
    
    return ret;
    

    }

    MY_IMAGE img1 = new MY_IMAGE();
    MY_IMAGE img2 = new MY_IMAGE();

    int nWidth = 864;
    int nHeight = 1000;

    img1.width = nWidth;
    img1.height = nHeight;
    img1.info = 8; // 8bit
    //img1.pbuf = new byte[2 *nWidth * nHeight];

    img2.width = nWidth;
    img2.height = nHeight;
    img2.info = 8; // 8bit
    //img2.pbuf = new byte[2 * nWidth * nHeight];

    //HOW TO DEFINE BYTE[] AND PIN AND THEN ASSIGN TO BUFFER?????

    ret = ScanSelectBuf(img1, img2, 0);

    Anything I am missing ???

    C# csharp c++ data-structures json performance

  • Calling C++ Image API from C#
    E econner

    Sorry for the latter code. Please ignore it. Maybe I can delete it.

    C# csharp c++ data-structures json performance

  • Calling C++ Image API from C#
    E econner

    Ok, I have looked a little more at your article. The Marshalling and pinning of the memory is something that I dont work with much. However, it does make sense with the type of memory error that I am receiving. So, from the original code I posted, how would you maybe suggest I change the stuct, DllImport, and calling methods to be in line with the Marshalling, pinning, and GCHandle? Would the parameter types change?

    C# csharp c++ data-structures json performance

  • Calling C++ Image API from C#
    E econner

    No, I have not. From the C++ example, they show setting the pbuf size, but with using IntPtr I was not sure how to accomplish the same thing.

    C# csharp c++ data-structures json performance

  • Calling C++ Image API from C#
    E econner

    Correct, on the buffer. Here is an excert from the docs: //Scan to buffer. int WScanSelectBuf(void* image_down, void* image_up ,int select) (param) image_down [out] structure for forward direction scan. image_up [in] NULL (reserved) select [in] 0 : forward direction & single scan (use image_down) 1 : backward direction & single scan (use image_up) 2 : both direction & single scan (use image_down & image_up) 3 : forward direction & dual scan (use image_down) 4 : backward direction& dual scan (use image_up) 5: both direction & dual scan (use image_down& image_up) Return value - Success 0, Fail > 0

    C# csharp c++ data-structures json performance
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups