RE: C# call to C++ static class raises NullReferenceException when web.config gets modifided

Discussion in 'ASP .Net' started by Steven Cheng[MSFT], Jan 9, 2004.

  1. Hi AAguiar,


    Thank you for the response. Regarding on the issue, I am finding proper
    resource to assist you and we will update as soon as posible. In the
    meantime, If you have any new findings, please feel free to post here.



    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Jan 9, 2004
    #1
    1. Advertising

  2. Steven Cheng[MSFT]

    AAguiar Guest

    OK. Thank you.
    I don't have new findings for now, but I'm continue working on this issue.

    I hope the example helps to reproduce the error.

    Any help would be greatly appreciated.


    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi AAguiar,
    >
    >
    > Thank you for the response. Regarding on the issue, I am finding proper
    > resource to assist you and we will update as soon as posible. In the
    > meantime, If you have any new findings, please feel free to post here.
    >
    >
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    >
    >
    >
     
    AAguiar, Jan 9, 2004
    #2
    1. Advertising

  3. Hi AAguiar,


    I'm still focus on this issue and trying to repro it via the code you
    provided. I'll let you know as soon as I've got any progress.


    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Jan 14, 2004
    #3
  4. Steven Cheng[MSFT]

    AAguiar Guest

    Ok. Thank you

    I hope you can reproduce the error with the supplied code, if you have any
    question about it, please ask me.


    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi AAguiar,
    >
    >
    > I'm still focus on this issue and trying to repro it via the code you
    > provided. I'll let you know as soon as I've got any progress.
    >
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    >
    >
    >
    >
     
    AAguiar, Jan 14, 2004
    #4
  5. Hi AAguiar,


    I'm sorry for keeping you waiting for so long time. Currently I've done
    serveral tests on the code you provided. However, some conditions are a bit
    different from your description, here is what I found:
    1. I tried build all the components without any strong-named, and test the
    handler following the repro steps you mentioned. then all is ok.

    2. As you said, the problem occured only when you build the "MyCrpto"
    component as strong-named. Did you also build the "EncodeDecode.dll" as
    strong-named? Did you use VS.NET IDE to build them? I used the VS.NET ide
    to build them and found that if only "MyCrypto" is strong-named and
    "EncodeDecode" is not strong-named , then when I try build the them,
    VS.NET will popup a exception said that "EncodeDecode" is not strong-named
    which will prevent me from successfully build the MyCrypto. So I'd like to
    confirm you with this.
    If you use other means to build all the assemblies which didn't occur such
    error, I think the cause of the problem is likely due to "EncodeDecode"
    assembly is not strong-named also.

    3. In addition, I've also test the case that I set both "EncodeDecode" and
    "MyCrypto" assembies as strong-named and then
    use them as the repro steps above in a ASP.NET web app. The result is the
    same as in 1, no exception occured.

    So please check out the suggestions I mentioned above. If you have any
    questions or new findings, please feel free to let me know.



    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Jan 17, 2004
    #5
  6. Steven Cheng[MSFT]

    AAguiar Guest

    Steven, thanks for the reply.

    1. Ok. I agree.

    2. Yes, I always built EncodeDecode.dll as strong name, and I used VS.NET
    2003.

    3. In this case is where I get the exception after I follow the 5 steps that
    I described in my previous post.

    I have windows xp and IE 6.0

    I think maybe I have different settings in the EncodeDecode project.

    Which settings do you have in your C/C++ Command Line and Linker Command
    Line ?.

    Thanks again.


    "Steven Cheng[MSFT]" <> wrote in message
    news:f95%23D$...
    > Hi AAguiar,
    >
    >
    > I'm sorry for keeping you waiting for so long time. Currently I've done
    > serveral tests on the code you provided. However, some conditions are a

    bit
    > different from your description, here is what I found:
    > 1. I tried build all the components without any strong-named, and test

    the
    > handler following the repro steps you mentioned. then all is ok.
    >
    > 2. As you said, the problem occured only when you build the "MyCrpto"
    > component as strong-named. Did you also build the "EncodeDecode.dll" as
    > strong-named? Did you use VS.NET IDE to build them? I used the VS.NET

    ide
    > to build them and found that if only "MyCrypto" is strong-named and
    > "EncodeDecode" is not strong-named , then when I try build the them,
    > VS.NET will popup a exception said that "EncodeDecode" is not

    strong-named
    > which will prevent me from successfully build the MyCrypto. So I'd like

    to
    > confirm you with this.
    > If you use other means to build all the assemblies which didn't occur

    such
    > error, I think the cause of the problem is likely due to "EncodeDecode"
    > assembly is not strong-named also.
    >
    > 3. In addition, I've also test the case that I set both "EncodeDecode"

    and
    > "MyCrypto" assembies as strong-named and then
    > use them as the repro steps above in a ASP.NET web app. The result is

    the
    > same as in 1, no exception occured.
    >
    > So please check out the suggestions I mentioned above. If you have any
    > questions or new findings, please feel free to let me know.
    >
    >
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
     
    AAguiar, Jan 19, 2004
    #6
  7. Hi AAguiar,

    Thanks for your reply and the further info you provided. I've attached the
    test solution which contains all the test projects. You may check on it to
    see whether there're any difference , also you can have a test on it on
    your side. If still remains the problem, I think we need to look for some
    other things for throubleshooting , do you think so? In the mean time, I'll
    do some further tests on my side to see whether I've lose any thing.
    If you have questions or any findings, please feel free to post here.


    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Jan 20, 2004
    #7
  8. Steven Cheng[MSFT]

    AAguiar Guest

    Steven,
    Thank you for sending me the test solution.
    I already tested it and I'm getting the same error.

    I agree with you, that we need to look for some other things for
    troubleshooting.

    The application is very simple; perhaps we have differences in other things
    like virtual directory or user's permissions:

    - My virtual directory ("services") isn't checked for anonymous access, and
    is checked for Integrated Windows Authentication.

    - The test user (which I'm logged in) is member of the Administrators group.

    - The error always disappears if MyCrypto.dll and EncodeDecode.dll haven't
    got a strong name, or if I set impersonation="false" in web.config file.

    It's very strange. Do you think that it would help if I reinstall aspnet ?.


    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi AAguiar,
    >
    > I'm sorry to forget attaching the project package in the last reply, I've
    > attached it in this one.
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    >
     
    AAguiar, Jan 20, 2004
    #8
  9. Hi AAguiar,

    Thanks for your response. Yes, in addtion to something with the code, the
    problem is likely due to some security related configuration settings.
    Currently, I'm still not sure on this since I've not repro the same error.
    However, I recommend that you try the code on other machine and see whether
    is able to repro this error. If not, try compare the different server
    enviroment or confirguation between the different machines. As for to
    reinstall the ASP.NET, I think you may try this in the end :). Meanwhile,
    I'll continue to try repro the problem on my side, and I'll update you as
    soon as I've any new update!


    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Jan 21, 2004
    #9
  10. Hi AAguiar,

    Please pardon the delay in answering your question. We are still
    researching and will post more information as soon as we can.

    Thank you, Mike
    Microsoft, ASP.NET Support Professional

    Microsoft highly recommends to all of our customers that they visit the
    http://www.microsoft.com/protect site and perform the three straightforward
    steps listed to improve your computer’s security.

    This posting is provided "AS IS", with no warranties, and confers no rights.


    --------------------
    > X-Tomcat-ID: 178918413
    > References: <>

    <>
    <>
    <>
    <>
    <f95#D$>
    <#>
    <H$>
    <>
    <>
    > MIME-Version: 1.0
    > Content-Type: text/plain
    > Content-Transfer-Encoding: 7bit
    > From: (Steven Cheng[MSFT])
    > Organization: Microsoft
    > Date: Wed, 21 Jan 2004 07:25:11 GMT
    > Subject: Re: C# call to C++ static class raises NullReferenceException

    when web.config gets modifided
    > X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    > Message-ID: <tQhqA$#>
    > Newsgroups: microsoft.public.dotnet.framework.aspnet
    > Lines: 21
    > Path: cpmsftngxa07.phx.gbl
    > Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:203794
    > NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
    >
    > Hi AAguiar,
    >
    > Thanks for your response. Yes, in addtion to something with the code, the
    > problem is likely due to some security related configuration settings.
    > Currently, I'm still not sure on this since I've not repro the same

    error.
    > However, I recommend that you try the code on other machine and see

    whether
    > is able to repro this error. If not, try compare the different server
    > enviroment or confirguation between the different machines. As for to
    > reinstall the ASP.NET, I think you may try this in the end :). Meanwhile,
    > I'll continue to try repro the problem on my side, and I'll update you as
    > soon as I've any new update!
    >
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    >
    >
     
    Mike Moore [MSFT], Jan 23, 2004
    #10
  11. Hi AAguiar,


    I've done some further tests following your repro steps. And I've a good
    news that I've also encountered an error when modified the web.config file
    and restart the web app to recycle the workerprocess. The difference is
    that what I met is a "Access Denied" error, which occurs in the "MyCrpto"
    components. Currently, I'm doing further research on it, it may cost
    certain period time to find the cause, but I'll notice you as soon as I've
    any new findings. If you have any new update, please feel free to post here.


    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Jan 23, 2004
    #11
  12. Steven Cheng[MSFT]

    AAguiar Guest

    Steven, thanks for your answers and your time.

    The solution I have found to the problem is to install the assembly
    EncodeDecode.dll in the GAC. If I uninstall the EncodeDecode.dll from the
    GAC the error comes again.

    I think that the NullReferenceException is related to the way the dlls are
    loaded. In fact I think that the order that the AspNET Worker process loads
    the dlls when it recycles them is different to the way they are loaded when
    it is restarted. This brings errors when the dlls are static, mixed (managed
    and unmanaged) and referenced by other ones. May when the dll is in the GAC
    the loading order changes ?

    At least now I don't have the error, but if you have any other suggestion to
    solve this problem please let me know.

    Thanks again and Regards.

    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi AAguiar,
    >
    >
    > I've done some further tests following your repro steps. And I've a good
    > news that I've also encountered an error when modified the web.config file
    > and restart the web app to recycle the workerprocess. The difference is
    > that what I met is a "Access Denied" error, which occurs in the "MyCrpto"
    > components. Currently, I'm doing further research on it, it may cost
    > certain period time to find the cause, but I'll notice you as soon as I've
    > any new findings. If you have any new update, please feel free to post

    here.
    >
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    >
    >
    >
    >
     
    AAguiar, Jan 23, 2004
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page