Click here to Skip to main content
15,886,199 members
Home / Discussions / C#
   

C#

 
QuestionHow can I use 3D modules(Such as DirectX or OpenGL)in my programming... Pin
hamidhesar2-Mar-11 0:37
hamidhesar2-Mar-11 0:37 
AnswerRe: How can I use 3D modules(Such as DirectX or OpenGL)in my programming... Pin
Pete O'Hanlon2-Mar-11 1:05
mvePete O'Hanlon2-Mar-11 1:05 
QuestionProblem in sending sms from pc to mobile through AT commands [modified] Pin
aeman1-Mar-11 23:27
aeman1-Mar-11 23:27 
AnswerRe: Problem in sending sms from pc to mobile through AT commands Pin
Thomas Krojer1-Mar-11 23:33
Thomas Krojer1-Mar-11 23:33 
QuestionAppDomain.CurrentDomain.SetData(SOME_SECRET_KEY, PrivateKey) [modified] Pin
devvvy1-Mar-11 22:53
devvvy1-Mar-11 22:53 
QuestionAssembly.GetExecutingAssembly - can we get "Key" which signed the assembly? Pin
devvvy1-Mar-11 22:49
devvvy1-Mar-11 22:49 
AnswerRe: Assembly.GetExecutingAssembly - can we get "Key" which signed the assembly? Pin
Keith Barrow1-Mar-11 23:23
professionalKeith Barrow1-Mar-11 23:23 
GeneralRe: Assembly.GetExecutingAssembly - can we get "Key" which signed the assembly? [modified] Pin
devvvy2-Mar-11 16:08
devvvy2-Mar-11 16:08 
I just tested, even if User dll loaded and proxy created on a separate AppDomain - User dll methods can still access "AppDomain.CurrentDomain.GetData("KEY1")!

<br />
***** Program.cs ***** <br />
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
<br />
using System.Reflection;<br />
using System.Security.Policy;<br />
<br />
using UserUtil;<br />
using SimpleUtil;<br />
<br />
namespace TestAppDomain<br />
{<br />
    class Program<br />
    {<br />
        public const string KEY1 = "KEY1";<br />
        public static AppDomain UserDomain = null;<br />
<br />
        static void Main(string[] args)<br />
        {<br />
            Assembly UserAssembly = null;<br />
            Object oProvider = null;<br />
            SimpleUtil.IServiceProvider UserProvider = null;<br />
<br />
            try<br />
            {<br />
                AppDomain.CurrentDomain.SetData(KEY1, "PrivateKey");<br />
<br />
                UserDomain = AppDomain.CreateDomain("UserDomain");<br />
                UserDomain.SetData(KEY1, "Sh*t!");<br />
                <br />
                UserAssembly = Assembly.LoadFrom("UserUtil.dll");<br />
                <br />
                oProvider = UserDomain.CreateInstanceFrom("UserUtil.dll", "UserUtil.ServiceProvider").Unwrap();<br />
                // oProvider = UserAssembly.CreateInstance("UserUtil.ServiceProvider");<br />
<br />
                if (oProvider != null)<br />
                {<br />
                    if (oProvider is SimpleUtil.IServiceProvider)<br />
                    {<br />
                        UserProvider = (SimpleUtil.IServiceProvider)oProvider;<br />
<br />
                        UserProvider.DoWork("Calling UserProvider.DoWork");<br />
                    }<br />
                }<br />
            }<br />
            catch (Exception Ex)<br />
            {<br />
                Console.WriteLine(Ex.Message);<br />
            }<br />
<br />
            return;<br />
        }<br />
    }<br />
}<br />
<br />
*** SimpleUtil.ServiceProvider ***<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
<br />
using System.Runtime.Serialization;<br />
<br />
namespace SimpleUtil<br />
{<br />
    [Serializable()]<br />
    class ServiceProvider : SimpleUtil.IServiceProvider<br />
    {<br />
        public void DoWork(string Message)<br />
        {<br />
            Console.WriteLine("SimpleUtil.DoWork");<br />
            return;<br />
        }<br />
<br />
        public ServiceProvider()<br />
        {<br />
            return;<br />
        }<br />
<br />
        public ServiceProvider(SerializationInfo info, StreamingContext context)<br />
        {<br />
            return;<br />
        }<br />
<br />
        public void GetObjectData(<br />
            SerializationInfo info,<br />
            StreamingContext context<br />
        )<br />
        {<br />
            return;<br />
        }<br />
    <br />
    }<br />
}<br />
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
<br />
using System.Runtime.Serialization;<br />
<br />
namespace SimpleUtil<br />
{<br />
    public interface IServiceProvider : ISerializable<br />
    {<br />
        void DoWork(string Message);<br />
    }<br />
}<br />
<br />
<br />
***** UserUtil.ServiceProvider *****<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
<br />
using System.Runtime.Serialization;<br />
<br />
using SimpleUtil;<br />
<br />
namespace UserUtil<br />
{<br />
    [Serializable()]<br />
    public class ServiceProvider : SimpleUtil.IServiceProvider<br />
    {<br />
        public void DoWork(string Message)<br />
        {<br />
            object oSecret = null;<br />
            string secret = null;<br />
<br />
            oSecret = AppDomain.CurrentDomain.GetData("KEY1");<br />
            if (oSecret != null)<br />
            {<br />
                secret = (string)oSecret;<br />
                Console.WriteLine("UserUtil.DoWork - secret=" + secret);<br />
            }<br />
            else<br />
            {<br />
                Console.WriteLine("UserUtil.DoWork - secret=NULL!");<br />
            }<br />
            return;<br />
        }<br />
<br />
        public ServiceProvider()<br />
        {<br />
            return;<br />
        }<br />
<br />
        public ServiceProvider(SerializationInfo info, StreamingContext context)<br />
        {<br />
            return;<br />
        }<br />
<br />
        public void GetObjectData(<br />
            SerializationInfo info,<br />
            StreamingContext context<br />
        )<br />
        {<br />
            return;<br />
        }<br />
    }<br />
}<br />
<br />


So, this is not going to work if intention of loading third party dll into separate appDomain is security. Not to mention, there are ways to enumerate app domains in the executing process[^]

Any suggestion how we can save sensitive data in AppDomain (using SetData/GetData) "safely"!?

Thanks
dev
modified on Wednesday, March 2, 2011 10:42 PM

QuestionHow to block read / write operation of cd/dvd [modified] Pin
Aisha sharma1-Mar-11 22:24
Aisha sharma1-Mar-11 22:24 
AnswerRe: How to block read / write operation of cd/dvd Pin
Keith Barrow1-Mar-11 22:55
professionalKeith Barrow1-Mar-11 22:55 
AnswerRe: How to block read / write operation of cd/dvd Pin
Dalek Dave7-Mar-11 11:22
professionalDalek Dave7-Mar-11 11:22 
QuestionLoad picture from resource file with XAML Pin
Mc_Topaz1-Mar-11 21:25
Mc_Topaz1-Mar-11 21:25 
AnswerRe: Load picture from resource file with XAML Pin
Pete O'Hanlon1-Mar-11 21:31
mvePete O'Hanlon1-Mar-11 21:31 
GeneralRe: Load picture from resource file with XAML Pin
Mc_Topaz1-Mar-11 21:36
Mc_Topaz1-Mar-11 21:36 
AnswerRe: Load picture from resource file with XAML Pin
ltuljo2-Mar-11 14:46
ltuljo2-Mar-11 14:46 
QuestionPostgres database connection Pin
Software20071-Mar-11 9:32
Software20071-Mar-11 9:32 
AnswerRe: Postgres database connection Pin
Orcun Iyigun1-Mar-11 9:38
Orcun Iyigun1-Mar-11 9:38 
GeneralRe: Postgres database connection Pin
Software20071-Mar-11 9:45
Software20071-Mar-11 9:45 
GeneralRe: Postgres database connection Pin
Dave Kreskowiak1-Mar-11 9:46
mveDave Kreskowiak1-Mar-11 9:46 
AnswerRe: Postgres database connection Pin
Dave Kreskowiak1-Mar-11 9:45
mveDave Kreskowiak1-Mar-11 9:45 
GeneralRe: Postgres database connection Pin
Software20071-Mar-11 9:56
Software20071-Mar-11 9:56 
AnswerRe: Postgres database connection Pin
Pete O'Hanlon1-Mar-11 9:56
mvePete O'Hanlon1-Mar-11 9:56 
GeneralRe: Postgres database connection Pin
Software20071-Mar-11 10:26
Software20071-Mar-11 10:26 
GeneralRe: Postgres database connection Pin
Pete O'Hanlon1-Mar-11 10:34
mvePete O'Hanlon1-Mar-11 10:34 
GeneralRe: Postgres database connection Pin
Software20071-Mar-11 10:40
Software20071-Mar-11 10:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.