|
So 'keystore' is a byte array I am using to initialize the RNGCryptoServiceProvider object. I could use nothing but thought this was more secure. I could not find enough info in the help files to tell me more, but I assumed since this is a Crypto object a key was a good idea.....
....Here I am getting the initial random object to be used below
Random rdm1 = new Random(unchecked((int)DateTime.Now.Ticks) * Environment.TickCount);
.....this is to be used by the RNGCryptoServiceProvider.GetBytes object method
.....as the passed in parameter
byte[] random = new Byte[100];
.....RNGCryptoServiceProvider is an implementation of a random number generator.
.....keystore is a byte array of random numbers used as a key
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(keystore);
try
{
.....here the byte array from above gets filled with random bytes
rng.GetBytes(random);
}
catch(CryptographicException e)
{
throw new ApplicationException("Random number generator threw an error:" + e.Message);
}
.....here we use a random byte from that array, chosen with the first Random object from above,
.....and times it by both the Environment.TickCount & DateTime.Now.Ticks
.....this makes sure we have a unique seed value every time.
int seed = ~unchecked((int)DateTime.Now.Ticks) * Environment.TickCount * random[rdm1.Next(random.Length - 1)];
......and we seed a new random object. I do this because I want to unique seed
Random rdm2 = new Random(seed);
I still get with a unique seed if I set the random max at 37 a patterned sequence
|
|
|
|
|
chris Lasater wrote:
I could use nothing but thought this was more secure. I could not find enough info in the help files to tell me more, but I assumed since this is a Crypto object a key was a good idea.....
Rule 1: Computers dont understand assumptions.
Rule 2: Read the help. It clearly says that method is not used. Also a decompiler confirms that the default contructor is just called. SO no harm done here.
Random gaurentees a random number from any of its get methods for a seed. Thus comparing random numbers from 2 different seeds is not valid.
Again I ask you, what you need this for? Are you just looking for a random number? A random byte sequence? Something else?
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
Hello All,
I am working on a piece of code that needs to write files to an output directory. The code should look in a generic container directory and see if there is subdirectory with the same name as the currently logged in user. If there is not it needs to create a directory with the same name as the currently logged in user and then set the permissions so that only admins and that user can access the folder. I can check for file existence just fine but I am having difficulty finding clear code examples of how to check and set directory permissions. The deployment machine will be Win2K participating in an Active Directory. Anyone have any links or code samples? The ADSI 2.5 chm code samples are all in C++ and I am unable to effectively interpret the code. I need C# or VB examples.
Thanks,
Derek
Derek Strickland
|
|
|
|
|
OK, here is the following situation I hoped .NET is capable of resolving simple and elegantly:
I'm using COM Interop while exposing my WinForm User Control as an ActiveX control to the system.
So, I defined my custom [default] and [default, source] interfaces, placed all methods and events in there and created CoClass like that:
[GuidAttribute("C776B7B8-F928-442A-AFB1-2864ECC98166")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IIn
{
....
}
[GuidAttribute("D776B7B8-F928-442A-AFB1-2864ECC98166")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IOut
{
.....
}
// Attributes of the class: specify GUID if needed
[GuidAttribute("B776B7B8-F928-442A-AFB1-2864ECC98166")]
[ComSourceInterfaces(typeof(IOut))] // default source interface
[ClassInterface(ClassInterfaceType.None)]// no need for AutoDual, public class ActiveXNet : UserControl, IIn
{
....
}
As you can see, everything is great and it's working, the problem is that exported Type Library has the following sequence in CoClass declaration:
[
uuid(B776B7B8-F928-442A-AFB1-2864ECC98166),
version(1.0),
custom(.....)
]
coclass ActiveXNet {
interface _Object;
interface IComponent;
interface IDisposable;
[default] dispinterface IIn; <== It's placed at the bottom!!!
[default, source] dispinterface IOut;
};
So, what a big deal you may ask? The big deal is that another MSFT product which is Developer Studio V6.0 as well as newest V7.0, both still have "small" bug --> when creating ActiveX Control wrappers using MFC (remember those CWnd Derived classes with CreateControl and alot of Invoke Methods). Unfortunately, instead of creating Wrappers for [default] interface those MSFT products are still creating wrapper for the first Interface in the CoClass definition: So, in case of above described ActiveXNet CoClass -- I'm getting wrapped methods of _Object interface... and of course they are of no interest to anybody.
If I change class attribute to: [ClassInterface(ClassInterfaceType.AutoDual)] <== AutoDual here: Then I'm getting right layout of CoClass definition in typelibrary:
[
uuid(B776B7B8-F928-442A-AFB1-2864ECC98166),
version(1.0),
custom(.....)
]
coclass ActiveXNet {
[default] interface _ActiveXNet; <== see here it's the first Interface
interface _Object;
interface IComponent;
interface IDisposable;
[default, source] dispinterface IOut;
};
However, that is not satisfactory solution, because it doesn't include my explicitly defined IIn interface.
As I was told .NET suppose to make my life as programmer easier, so I've spend about 2 days now trying to figure out and find that "simple" solution. However, I'm giving up on doing it on my own and presenting you the problem, so you may demonstrate all of us yours "GURU" skills.
So, the question is: how can I easily rearange layout of TypeLibConverter::ConvertAssemblyToTypeLib.
I know about ICreateTypeLib and ICreateTypeInfo possible solutions, but would consider using them as introducing unnecesary overhead and complexity to the problem that CLR solution should resolve like a "piece of cake".
Maybe, there is some kind of an Attribute I don't knbow about and or etc...
Thanx in advance
|
|
|
|
|
If the IDL has a [default] attribute at the wrong place, I would reopen it using OLEViewer, grab the IDL definition, change it, and recompile the tlb.
|
|
|
|
|
You are "joking", Right?... You mean each time i'm creating ActiveX Assembly supporting COM Interop with AutoDual.None, I should manually after the build go in there grab IDL, goto OleView, export it, edit it, save then run MIDL, then rerregister (possibly resign?)...
You are joking, I'm sure!
I resolved it by using ICreateTypeLib2, eventhough it was tricky. But my point was:
MS talks about perfect CLR future, while still having inherited since about 10years ago bugs here and there, that haven't been fixed.
I was surprised recently, that even kernel FindResource function behaves differently on NT, 2000 and XP and doesn't follow documentation.
Yes, MSFT fixed IPersistStreamInit interface of WinForm Controls in .NET 1.1 -- however IPesristMemory still doesn't work.
IOleObject::SetClientSite returns E... NOT_IMPLEMENTED.
BTW: thanx for defending me about 1 year ago from one of the racist IDIOTS.
Regards,
Igor
|
|
|
|
|
That was an idea to solve the issue. It's true that what you say : "You mean each time i'm creating ActiveX Assembly..." brings a different perspective since it implies you are writing many ActiveX components. The proposed solution is fine if you just do it once. This was more or less implied anyway.
igor1960 wrote:
I was surprised recently, that even kernel FindResource function behaves differently on NT, 2000 and XP and doesn't follow documentation.
I am not surprised, those are 3 rather different codebases. But of course, one feels like insulting MS when the thing to be used doesn't behave the same depending on the underlying OS, and as such requires significant time and work to get around.
I am afraid it's got to worsen. Guess what's going to happen when your boss says let's make a Windows.CE compatible version of the software.
At the end of the day though, that's what differentiates real great developers from others. Great developers get around those things, because they have the necessary background.
igor1960 wrote:
BTW: thanx for defending me about 1 year ago from one of the racist IDIOTS.
Quite honestly, I don't remember this at all.
|
|
|
|
|
|
igor1960 wrote:
yesterday I've suddenly rediscovered that thread and found your message
Oh, that was a spicy thread !
igor1960 wrote:
How long usually it takes to place an article on CP?
It usually takes one week. Unfortunately, Chris is currently in Redmond (if I understood well) so the article processing gets somewhat deferred one week or so.
Once the article gets in the pipe, that is once Chris has reached your email out of his billions emails, then you will be sent an automated email.
Once you have this email, it takes a few days before it gets edited by the editors and actually gets posted.
Should be posted soon now.
|
|
|
|
|
Hello everyone.
I test on a dll called wenching.dll. Just an example.
I use the vs.net command prompt and type this command:
tlbimp wenching.dll
I got this error:
TlbImp error: The input file 'C:\Windows\system32\wenching.dll' is not a valid type library
Hmm.. what does this mean?
But when i try this:
tlbimp dx7vb.dll
it works fine?
Any help?
Regards,
Chua Wen Ching :p
|
|
|
|
|
|
Hi All,
I would like to install visual JSharp from command line in silent mode. But i could not yet get a solution for that. Any help in this regard is much more helpful to me.
Thanks,
S. Seetha Raman.
|
|
|
|
|
Is there any wrapper for telephony in .NET, or do I have to call the TAPI directly?
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
I'm going with TAPI 3.0 - it uses COM.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Hi,
... I'm new to all this Pocket Pc stuff... I would like to launch a process ( or configure ActiveSync), in order to copy an XML file from my PC to the Pocket Pc, and the other way around when the user places the pocket in the cradle.
Any idea about how to do this ?, Thanks in advance
Braulio
|
|
|
|
|
I have released v1.2 of my Code Store[^] add-in for VS.NET, which does work (for the most part). Now I want to move on and add a better user interface and proper handling of settings before adding some more useful functionality.
I started by using ISerializable to serialize the settings, but had problems, so I switched to the Microsoft Configuration Management Application Block (CMAB[^]), but now I have hit yet further problems with this, that I have posted a question about on the microsoft.public.dotnet.distributed_apps newsgroup.
What I really need is someone (or some people) who know what they're doing to come in and fix these intial problems so that I can get on with the serious business of adding functionality. If you are interested and think you can help, then please wander over to GotDotNet Workspaces[^] and dowmload the code.
There are also issues relating to add-in registration and the setup of the menu item, etc. that would also be good to fix asap.
Derek Lakin.
Try the Code Store for instant integrated access to an online repository of .NET components.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Derek Lakin wrote:
Microsoft Configuration Management Application Block
Now that sounds nice Something that has been missing for while!
What seems to be the problem though? Also, can you provide a single file "solution" (no pun intended) to download, or specify the "bad" files in question?
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
OK, so I find your options.cs file But where are you using the CMAB?
AFAIKC, this is the implemention (2 ways):
...
ConfigurationManager c = ConfigurationManager.Items;
...
c["mysetting"] = Blah.Blah.Foo;
c["font"] = WebDongs;
...
OR
ConfigurationManager.Items["connection_string"] = "Some String";
string conString = (string)ConfigurationManager.Items["connection_string"];
The Read/Write methods are "extras".
Hope this helps
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
Just to check if everything was going wrong I added a call to Initialise in the Options constructor: ConfigurationManagaer.Initialise() . This is the first place that the exception is thrown.
However, the call to Initialise should not be necessary, so the first place I should be calling CMAB is in the Options.LoadOptions call: this.configData = ConfigurationManager.Read();
Derek Lakin.
Try the Code Store for instant integrated access to an online repository of .NET components.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Did you add the :
<section name="applicationConfigurationManagement" type="Microsoft.ApplicationBlocks.ConfigurationManagement.ConfigurationManagerSectionHandler,Microsoft.ApplicationBlocks.ConfigurationManagement, Version=1.0.0.0,Culture=neutral,PublicKeyToken=null" />
Section to your appfile.config file?
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
Yes, the App.config file is as follows:
="1.0"="utf-8"
<configuration>
<configSections>
<section
name="applicationConfigurationManagement"
type="Microsoft.ApplicationBlocks.ConfigurationManagement.ConfigurationManagerSectionHandler,Microsoft.ApplicationBlocks.ConfigurationManagement, Version=1.0.0.0,Culture=neutral,PublicKeyToken=null" />
<section
name="CodeStore"
type="Microsoft.ApplicationBlocks.ConfigurationManagement.XmlHashtableSectionHandler,Microsoft.ApplicationBlocks.ConfigurationManagement,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null" />
</configSections>
<CodeStore>
<XmlSerializableHashtable xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Entries>
<Entry>
<key xsi:type="xsd:string">serverUrl</key>
<value xsi:type="xsd:string">http://www.salamandersoftware.biz/codestore/</value>
</Entry>
<Entry>
<key xsi:type="xsd:string">localPath</key>
<value xsi:type="xsd:string"></value>
</Entry>
<Entry>
<key xsi:type="xsd:bool">useProxy</key>
<value xsi:type="xsd:bool">false</value>
</Entry>
<Entry>
<key xsi:type="xsd:bool">bypassProxyOnLocal</key>
<value xsi:type="xsd:bool">false</value>
</Entry>
<Entry>
<key xsi:type="xsd:bool">proxyAuthorisation</key>
<value xsi:type="xsd:bool">false</value>
</Entry>
<Entry>
<key xsi:type="xsd:string">proxyAddress</key>
<value xsi:type="xsd:string"></value>
</Entry>
<Entry>
<key xsi:type="xsd:int">proxyPort</key>
<value xsi:type="xsd:int"></value>
</Entry>
<Entry>
<key xsi:type="xsd:string">proxyUser</key>
<value xsi:type="xsd:string"></value>
</Entry>
<Entry>
<key xsi:type="xsd:string">proxyPassword</key>
<value xsi:type="xsd:string"></value>
</Entry>
</Entries>
</XmlSerializableHashtable>
</CodeStore>
<applicationConfigurationManagement >
<configSection name="CodeStore">
<configProvider assembly="Microsoft.ApplicationBlocks.ConfigurationManagement,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null"
type="Microsoft.ApplicationBlocks.ConfigurationManagement.Storage.XmlFileStorage"
refreshOnChange="false"
signed="false"
encrypted="false"
path="codestore.options" />
</configSection>
</applicationConfigurationManagement>
</configuration>
By all means join as a member of the GotDotNet workspace project. I'll let you in and check-in whatever files you think need changing.
Derek Lakin.
Try the Code Store for instant integrated access to an online repository of .NET components.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Hi all,
I spent almost one day to find out why do i receive unhandled exception when trying to select multiple rows in a form's DataGrid. I will get the error if I put a DataGrid to a form and choose any unexpandable data source (for e.g. an ArrayList), which produces readonly DataGrid by default. If I start to select the last 2 rows in my readonly DataGrid with the keyboard (<shift>+<crsr down="">) and keep my fingers on the keyboard for a while (trying to select the unexisting rows), then pressing a <shift>+<crsr up=""> leads to crash.
If the DataGrid is not read only, then working fine. (only the DataGridTableStyle can be readonly to avoid the exception)
I could not believe my eyes, so I downloaded an MS example, called "datagridcustomization.exe" from http://download.microsoft.com/download/c/9/8/c985dbd0-2ba9-4c75-86ba-a108e64b0970/datagridcustomization.exe
but this produced something new, which is also strange.
just unpack the example and run the program found under the /bin directory and simply press the <crsr down=""> key until you reach the end of the datagrid
since i just started to learn .Net framework, i do not know if this kind of component behavior is normal or not?
Is there any global exception handling possibility to handle such exceptions?
thanks
|
|
|
|
|
Ok guys, I've been wrestling with this for a while now and am not getting anywhere. I just can't get MS Visual Studio to recognize my 1.1 .NET SDK update. I'm on a win 2K machine and have VS .NET professional installed (which installs the 1.0 SDK be default).
When I try installing the 1.1 SDK over the 1.0, VS .NET doesn't recognize the update. It says (under help->About Microsoft Development Environment) that I have the 1.0 framework installed. I get no errors when installing the 1.1 SDK, and am installing the 1.1 runtimes first, before the sdk.
Ive tried uninstalling 1.0 SDK, and then reinstalling 1.1. When I did this MS Visual Studio gives me errors and says I need to reinstall VS.
Any ideas? At the very least can someone give me the order in which I should install/uninstall everything? I may end up just moving to a different/fresh machine and starting over.
Thanks for any help
Dave Ratti
|
|
|
|
|
Are you using Visual Studio 2002? Visual Studio 2002 only targets NET 1.0 .You can not use the .NET 1.1 from within Visual Studio 2002.
To build a .NET 1.1 App you have two options:
1. Use Visual Studio to write and organize your files and then use the command line compiler on the 1.1 SDK folder to build your app (but remember that NET 1.1 introduces some code-breaking changes to NET 1.0)
2. Upgrade to Visual Studio 2003
|
|
|
|
|
Yeah I am using VS 2002, thanks for the help
Update: urgh is $550 for the upgrade
|
|
|
|
|