C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2722
Number of posts: 5749

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
NET DLL nightmare Posted by ferroariel on 27 Apr 2009 at 7:48 PM
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-responder-add-in-for-windows-live-messenger/

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

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:

"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
Report
Re: NET DLL nightmare Posted by Psightoplazm on 28 Apr 2009 at 8:05 AM
Why aren't you using a WebClient?

var m = new WebClient();
var result = m.DownloadString("http://www.google.com/search?hl=en&q=test&aq=f&oq=");
MessageBox.Show(result);


I'm only asking this because it looks like you are just wanting to submit a basic GET url and receive the result in a string.

></\/~Psightoplasm`~
Report
Re: NET DLL nightmare Posted by ferroariel on 28 Apr 2009 at 1:33 PM
I have never tried that before.... I'll give it a try and let you know... But, what's the difference between the WebClient approach and the one I used??

GLAD you wrote!!!
Ariel
Report
Re: NET DLL nightmare Posted by Psightoplazm on 28 Apr 2009 at 1:56 PM
well all the stuff you were doing is actually done inside the WebClient - plus it handles all protocols and securities for basic page browsing. - it's like one step down from the WebBrowser object that actually renders the pages and runs scripts and all that.

At least that's my understanding of it. :)

></\/~Psightoplasm`~
Report
Re: NET DLL nightmare Posted by ferroariel on 28 Apr 2009 at 4:15 PM
No luck at all... same error using WebClient object,
dunno ... tks anyway...
Ariel
Report
Re: NET DLL nightmare Posted by Psightoplazm on 28 Apr 2009 at 6:14 PM
Is there some kind of firewall or protection system that may allow your web browser to access the internet, but not other applications on the machine you are running from?

Vista I think by default is set up to do this.

Or - are you running through a proxy? You might need to set up the proxy on the WebClient.

Using the web client should be able to assure you there is nothing wrong with your code as far as accessing a web page, so something externally must be blocking or not allowing your application access to the outside world.

Also - do you have to log into your site? Does it need a cookie or any kind of authentication in order to access the page you are accessing?

></\/~Psightoplasm`~
Report
Re: NET DLL nightmare Posted by Psightoplazm on 28 Apr 2009 at 6:15 PM
dammit - this thing keeps double-posting



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.