CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2009
    Posts
    2

    Angry .NET DLL NightMare!!!

    Hi u all!!!

    I have a website, dedicated to beauty products for women, ok? Sometime ago a friend of mine told me "hey! why don´t you send that info through MSN?". I liked that, so I downloaded an autoresponder code from here:

    http://nayyeri.net/blog/auto-respond...ive-messenger/

    So I simply added this routine to get search results from my site:

    Code:
    public string getSiteSearchResults()
            {   string reader = "";
                string search = "[the received message text goes here]";
                string url = "[the URL of my website search page]?query="+ search;
                try            
                {
                    WebPermission pWeb = new WebPermission(NetworkAccess.Connect, url);
                    SecurityPermission pSec = new SecurityPermission(SecurityPermissionFlag.AllFlags);
                    PermissionSet set = new PermissionSet(PermissionState.None);
                    set.AddPermission(pWeb);
                    set.AddPermission(pSec);
                    set.Assert();
                    HttpWebRequest URLReq = (HttpWebRequest)WebRequest.Create(url);                
                    URLReq.Credentials = CredentialCache.DefaultCredentials;
                    URLReq.AuthenticationLevel = System.Net.Security.AuthenticationLevel.None;
                    URLReq.AllowAutoRedirect = true;
                    URLReq.Timeout = 60000;                
                    HttpWebResponse URLRes = (HttpWebResponse)URLReq.GetResponse();                
                    Encoding enc = Encoding.GetEncoding(1252); 
                    StreamReader sStream =   new StreamReader(URLRes.GetResponseStream(), enc);            
                    reader = sStream.ReadToEnd();                
                }
                catch (Exception ex)
                {
                    reader = ex.Message ;
                }                       
                return (reader);                
            }
    So when somebody asks for some product, the addin (working on one of my pcs) do a search on my site, get the results and send ´em in response as plain text.

    Well, instead of that, all I get is this:

    Code:
    "Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
    I read about gacutil, regasm, caspol, trust zones, trusted assembly, security zones...... but don´t have a clue where to start to get rid of this thing, really.

    Any help is truly appreciated

    Txs in adv

    Ariel

  2. #2
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: .NET DLL NightMare!!!

    Try to run the you code under another account than ASPNET which I suppose it run under. Just for a test to determine if it works. ASPNET is quite restricted and you have to figure out which permission you need and assign it to the account, or run you shop in separate application pool under dedicated account with appropriate rights.
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

  3. #3
    Join Date
    Apr 2009
    Posts
    2

    Unhappy Re: .NET DLL NightMare!!!

    mmm I'm not sure what are u talking about....

    Let me explain, I just created a .NET dll in Visual Studio 2008

    I just used VStudio 2008 to write it -C# dll project
    I've got a version of MSN Messenger which supports addins, and then went to the "Addins" tab and added my dll to it, so I turned it on and so on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured