Encrypted XML

This is a discussion on Encrypted XML within the C# Programming forums, part of the General Programming Boards category; Hi, I'm trying to follow a tutorial on the MSDN site to encrypt an Xml doc within C#. Code: EncryptedXml ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    329

    Encrypted XML

    Hi,

    I'm trying to follow a tutorial on the MSDN site to encrypt an Xml doc within C#.

    Code:
    EncryptedXml eXml = new EncryptedXml();
    I cannot find the EncryptedXml class. I have included all the Security namespaces, etc, but its still not coming on. Anybody any ideas?

    Thanks,

    Darren.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    Add the System.Security reference.

  3. #3
    Registered User
    Join Date
    Feb 2009
    Posts
    329
    Quote Originally Posted by Fordy View Post
    Add the System.Security reference.
    Hi,

    Thanks for the response, but I have included that.

    The following is what I am 'using':

    Code:
    using System;
    using System.Xml;
    using System.Security.Cryptography;
    using System.Security.Cryptography.Xml;
    using System.Security;
    I am using VS2008 if that makes any difference.

    Thanks,

    Darren.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    Yes, but as well as using, you need to add the reference. This usually appears under "References" under the Solution Browser

  5. #5
    Registered User
    Join Date
    Feb 2009
    Posts
    329
    Thank you very much. That works fine now.

  6. #6
    Registered User
    Join Date
    Feb 2009
    Posts
    329
    I am very much a beginner with C#, Any new namespace that I 'use' must I also ensure that the reference is included or does it only apply to a select few?

    Thanks.

  7. #7
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    A lot of them are usually included by default by Visual Studio, but if you get caught out have a look in the references for a likely candidate - you get the same kind of thing in most languages (libs in C, jars in Java, eggs in Python, etc...), but its easier in C# as you can open the Object Browser in Visual Studio and search around until you find it. Sometimes the component you need will come from a third party dll but if its a Microsoft component or already installed you should find it

  8. #8
    Registered User
    Join Date
    Feb 2009
    Posts
    329
    Aah right okay. So the references are similar to #include<> in C++ and the using, is basically just for the namespaces?

  9. #9
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,045
    It sounds like adding a reference in C# is like linking with the .a or .lib library in C++ that actually contains the code you're referring to. #include statements in C++ bring declarations (functions, classes, etc) into the current scope so that the compiler knows what "cout" means, for example; more modern languages like Java (and presumably C#, just a guess) don't really have an equivalent. In Java you can refer to a class if all you have is the .class or .jar file (like a C++ .a file, just contains the code). I'd guess too that the using statement in C# is much the same as C++'s and Java's, in that you could refer to the class with its fully qualified name, but the using statement brings the class into the current namespace so that you can use a shorter name to refer to it.

    As you can tell, I don't know any C# at all. :P Take with a grain of salt and much googling.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  10. #10
    Registered User
    Join Date
    Feb 2009
    Posts
    329
    Thanks for the input. I have got it on my 'to do list' as one to read up on.

    Cheers!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. XML string to dataset/datagrid?
    By Striph in forum C# Programming
    Replies: 3
    Last Post: 05-02-2010, 09:11 PM
  2. Parsing Xml
    By deviousdexter in forum C# Programming
    Replies: 7
    Last Post: 04-24-2009, 06:29 AM
  3. XML encoding issue
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-16-2008, 05:21 AM
  4. XML and data exchange
    By seexml in forum C Programming
    Replies: 0
    Last Post: 04-27-2006, 03:02 PM
  5. Need help with this xml tree example
    By kzar in forum C Programming
    Replies: 1
    Last Post: 11-22-2004, 10:23 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21