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
N

nilarya

@nilarya
About
Posts
6
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • generate custom xml from a dynamic dataset
    N nilarya

    Hi All, I dont know if this question is for this forum or I should post it on XML forum. I will transfer the question if you think it is more suitable on that forum. However, I have a asp.net application in C# where I have a dataset which I can transfer to xml by using the following simple codeblock

    string result;
    using (StringWriter sw = new StringWriter())
    {
    ds.WriteXml(sw);
    result = sw.ToString();
    }

    It generates the default xml of the table structure like the following:

    1
    untitled.bmp
    Some Path
    800
    190
    256
    1
    image/jpeg
    

    But I want the xml to be generated in the following format

    1
    untitled.bmp
    Some Path
    800
    190
    256
    1
    image/jpeg

    this is an example with dataset having one row. there are various rows in a dataset. In my application, I wont be knowing the structure of the dataset beforehand. i.e. there can be a resulting dataset where I have more columns than the one described in the example. How should I go about this? Any help would be much appreciated. Thanks.

    ASP.NET csharp question asp-net xml help

  • COM Component Late binding trouble
    N nilarya

    Hi again, I have finally got this COM object to work, but some problem still remains. I changed the code as following:

    ...
    using System.Threading;

    namespace...
    protected void Button1_Click(object sender, EventArgs e)
    {
    Thread thread = new Thread(new ThreadStart(STAOperation));
    thread.SetApartmentState(ApartmentState.STA);
    thread.Start();
    thread.Join();
    }
    public void STAOperation()
    {
    CSViewerRL.ViewerClass csv = new ViewerClass();
    csv.Open(filePath, 0, 0);//strange error
    //other codes..
    }

    this code works, but once in a while, I am getting a strange error while debugging, which states AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. generally the app runs fine the first time I try to debug, but this error occures mostly on the second or third time I press f5 from my VS while the ASP.Net server is still running. and generally it goes away if I stop the server and run again. I think this problem is because of this new STA thread. Maybe I am not handling the new thread correctly. Or there is some other thing I should look into? Can someone point out whatshould I do under this circumstance?

    COM csharp asp-net wpf wcf com

  • COM Component Late binding trouble
    N nilarya

    Hi, I just found the url http://www.guidanceshare.com/wiki/Interop_(.NET_1.1)_Performance_Guidelines_-_Threading[^] where it talks about using ASPCOMPAT attribute on the page while calling STA Objects from asp.net. I will give it a try.

    COM csharp asp-net wpf wcf com

  • COM Component Late binding trouble
    N nilarya

    Thanks Tom, I checked the registry, and you are right again. The value of ThreadingModel is defined as Apartment in there. So does that mean there is no way I can access the component in an asp.net codebehind? is there a workarround for this issue?

    COM csharp asp-net wpf wcf com

  • COM Component Late binding trouble
    N nilarya

    tom-englert wrote:

    Since you can't do early binding with that interop, it must have been already messed up, so I would not rely on the information provided by it.

    Thanks tom-englert for your response. Sorry for replying late. I was working on a different module during this time. you are right, I have examined the CLR-interop version of the component in ILDASM. But I wont say the component has been messed up as I can achieve desired results from the component with the exact same codes in case of a winforms application. In winforms both early binding and latebinding is working for me. I am also able to talk to the Component through Javascript block. But I need this component to run on my codebehind. I've tried installing OleView previously, but I am using Win7 in my development environment, It seems OleView is not supported in Win 7.

    COM csharp asp-net wpf wcf com

  • COM Component Late binding trouble
    N nilarya

    Hi All, I have posted this message earlier on the ASP.Net forum, I did not notice there is a separate forum for Co Componenets. However I am moving the post to here, please have a look, any help would be much appreciated. I am using a third Party Com Component in my ASP.NET application. I dont have much experience with COM Components and I think I have messed up here. Please help. The Com component has a method which looks like following in the ILDASM: .method public hidebysig newslot specialname virtual instance class [stdole]stdole.IPicture marshal( interface ) get_Preview([in] float64 rWorldMinX, [in] float64 rWorldMinY, [in] float64 rWorldMaxX, [in] float64 rWorldMaxY, [in] int32 dwPicWidth, [in] int32 dwPicHeight, [in] int32 PicType) runtime managed internalcall In my code behind, I am using

    object ComObjLateBound;
    Type ComObjType;
    ComObjType= Type.GetTypeFromCLSID(new Guid("{89251546-3F1C-430D-BA77-F86572FA4EF6}"));
    ComObjLateBound= Activator.CreateInstance(ComObjType);

    //getting the values from the properties. The properties are in the Com Component
    double viewMaxX = (double)ComObjType.InvokeMember("ViewMaxX", BindingFlags.Default | BindingFlags.GetProperty, null, ComObjLateBound, new object[] { });
    double viewMaxX = (double)ComObjType.InvokeMember("ViewMaxY", BindingFlags.Default | BindingFlags.GetProperty, null, ComObjLateBound, new object[] { });
    double viewMaxX = (double)ComObjType.InvokeMember("ViewMinX", BindingFlags.Default | BindingFlags.GetProperty, null, ComObjLateBound, new object[] { });
    double viewMaxX = (double)ComObjType.InvokeMember("ViewMinY", BindingFlags.Default | BindingFlags.GetProperty, null, ComObjLateBound, new object[] { });

    //geting the image height and width from a local file
    int imagewidth, imageheight, pictype;
    imagewidth = 1280; imageheight = 800; pictype = 1;

    object[] previewDetails = new object[7];
    previewDetails[0] = viewMinX;

    previewDetails[1] = viewMinY;

    previewDetails[2] = viewMaxX;

    previewDetails[3] = viewMaxY;

    previewDetails[4] = imagewidth;

    previewDetails[5] = imageheight;

    previewDetails[6] = pictype;

    IPicture picture = (IPicture)ComObjType.InvokeMember("get_Preview", BindingFlags.Default | BindingFlags.InvokeMethod, null, ComObjLateBound, previewDetails);

    this fails with a COM Exception like {"Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))"} with an ErrorCode of -2147352570 if that means something. Now this is strange

    COM csharp asp-net wpf wcf com
  • Login

  • Don't have an account? Register

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