|
imho the "best explanations" of .NET memory allocation using Stack and Heap are contained in three blog entries by Eric Lippert (a "major player" in the creation of .NET, and a very articulate writer): [^], [^], [^].
If these three articles were a movie, I'd give it the tag-line: "Memory moves in mysterious ways."
«I'm asked why doesn't C# implement feature X all the time. The answer's always the same: because no one ever designed, specified, implemented, tested, documented, shipped that feature. All six of those things are necessary to make a feature happen. They all cost huge amounts of time, effort and money.» Eric Lippert, Microsoft, 2009
|
|
|
|
|
am new to c# programming and for 3 months i've been learning and writing an application which am almost done, i have my user authen table for login purpose,profile table, features table, actions table as well as permission table in place in Msql database and also successful in inserting new permissions to database from winform and assigning those profile to a user. what am left to do is give permission right to users logon to access certain controls on my numerous winforms. am actually stuck here and dont know how to link application to read from database what permissions was assigned to a user and what controls to deny or permit. any help as to how to achieve this would be appreciated thank you.
Question is how do i make application read permission already assigned to a user and block or enable a control based on permissions assigned to that user.
|
|
|
|
|
We really can't give you a specific reply to this: we have no idea at all how your app works.
But I'd assume that you have a "logged in user" instance of a User class or similar - and I'd keep permissions as an enum property of that class, most likely.
So as part of your various Form.Load event handlers, check your user permissions and either set the appropriate Control.Enable or Control.Visible properties to false if the aren't allowed. (Or better, default to false and set to true if they are allowed).
But myself, I wouldn't do that - I would have "admin only" forms, which are only displayed if the user is permitted, and disable access to those instead.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
it works pretty simple, during development phase i had to manually insert permission by IDs in permissions table and assigned to a profile table by profile ID. but now am able to insert permissions on winform by checking and unchecking checkboxs and saves them to database so now all i want to is to read those permissions stored when a user logs in and also in the permissions table are columns for actions which are buttons found on all winform so if that particular user do not have that action then it should be disabled when that form is opened.
|
|
|
|
|
Yes - but we have no idea how the rest of your application works!
You can clearly access the DB (or you couldn't log them in at all) so read the access permissions then, and store them as part of your logged in user.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
could u please demonstrate that thanks
|
|
|
|
|
Demonstrate what? How to use an enum?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
|
|
Congratulatons on getting as far as you've gotten on this project !
I recently wrote a long post here in response to a question on the "Design and Architecture Forum" describing what I think is fairly secure approach to having a WinForms Application provide customized forms to use based on Groups/Roles: [^].
CHill's response here: [^] to the first post of that question may be of interest to you.
I think you might find some ideas on that thread, and I'll be happy to respond to any questions you may have about my post.
«I'm asked why doesn't C# implement feature X all the time. The answer's always the same: because no one ever designed, specified, implemented, tested, documented, shipped that feature. All six of those things are necessary to make a feature happen. They all cost huge amounts of time, effort and money.» Eric Lippert, Microsoft, 2009
|
|
|
|
|
I have the following error "Only one usage of each socket address (protocol/network address/port) is normally permitted" in my coding. Need Help!!
|
|
|
|
|
Please edit your question and show the code that creates the error.
|
|
|
|
|
Angry Children Problem of hackerrank
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution
{
static void Main(String[] args)
{
long N = Convert.ToInt64(Console.ReadLine());
long K = Convert.ToInt64(Console.ReadLine());
long[] list = new long[N];
for (long i = 0; i < N; i++)
{
list[i] = (Convert.ToInt64(Console.ReadLine()));
}
long b;
for (long k = 0; k < list.Length - 1; k++)
{
for (long i = 0; i < list.Length - k - 1; i++)
{
if (list[i] < list[i + 1])
{
b = list[i + 1];
list[i + 1] = list[i];
list[i] = b;
}
}
}
long x = list[0] - list[N - 1];
long j = K - 1;
for (long i = 0; i <=N-K ; i++)
{
if ((list[i] - list[j]) < x)
x = list[i] - list[j];
j++;
}
Console.WriteLine(x);
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */
}
}
|
|
|
|
|
Is there a reason you are posting your homework here?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
What benefit to you would it be if you get a solution to a challenge on HackerRank [^] that is not your solution ?
«I'm asked why doesn't C# implement feature X all the time. The answer's always the same: because no one ever designed, specified, implemented, tested, documented, shipped that feature. All six of those things are necessary to make a feature happen. They all cost huge amounts of time, effort and money.» Eric Lippert, Microsoft, 2009
|
|
|
|
|
Hi,
First time poster long time reader.
Im having trouble with a shdocvw.dll and accessing internet pages. Particulary interacting with them.
1.my setup windows 8 64bit running visual studio 2012, ie11.
Im only having the trouble on 64 bit machines, 32 bit machines run the program fine. i wrote a sample a small sample to show you want i mean: The following runs fine on the x86 computers and i get my hello world message... but any 64bit machines i get an error. i have tried runing in x86 mode only, x64 mode only all error.
This is just a sample code to demonstrate whats doesnt work.
SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer();
ie.Navigate("https://www.google.com.au");
while (ie.Busy)
{
}
ie.Visible = true;
string javaScriptcode = "alert('hello world !!')";
ie.Document.parentWindow.execScript(javaScriptcode, "javascript");
Ive run on ie 11 and ie8 on a x86 machines no worries. on the x64 machine with the the same ie security settings etc on ie11 give the error:
An unhandled exception of type 'System.UnauthorizedAccessException' occurred in System.Dynamic.dll
Additional information: Access is denied.
Id appreciate any help as ive exhausted google. Whats got me stumped is why it works in x86 machines but not in x64
David
|
|
|
|
|
In which line does the error occur?
SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer() ; creates a new instance of Internet Explorer, and an iexplore process becomes visible in e.g. Task Manager.
Is that a 32bit or a 64bit process?
Did you check the security settings of that specific version, in comparison to IE on 32bit systems?
|
|
|
|
|
Thank you Bernhard,
Sorry i should have said its on the exescipt line calling java script.
checked and its shdocvw is launching 32 bit verison which is good.
When you talked about security settings i checked. From what i can see there all the same... I then read something about protected mode. where i read that if you use shdocvw you will run in protected mode.
from the msdn.
Quote: Furthermore, extensions that attempt to gain write access to securable objects by using an API function in one of the following binary files will receive Access Denied errors.
actxprxy.dll ieui.dll mswsock.dll sensapi.dll
Advapi32.dll iexplore.exe NAPINSP.dll Shdocvw.dll
Would that be whats going on? I still cant understand why its only happening on 64 bit machines.
|
|
|
|
|
Are you using SHDocVw as a control within your application or are you using SHDocVw to startup Internet Explorer and then attempting to communication with an open IE window?
If the latter, then setting up a secure HTTPS connection is going to resist your injecting JavaScript into IE. x64 versions of windows have more strict protection mechanisms in place when communicating with 32-bit applications. Have you tried an HTTP connection instead of HTTPS?
Lastly, using the browser controls included in .NET work well if you modify the browser's emulation mode[^] for your application. You must do this to use HTML5 in your desktop application or if will look and run like crap. After changing the emulation mode in the registry, I find the included WebBrowser control does all I ask of it. HTML5 within the WebBrowser control rocks.... I kicked SHDocVw to the curb years ago.
Later.....
|
|
|
|
|
hi . please ee this image:
http://i57.tinypic.com/16iy7i8.png[^]
How can i create a Class tag and relationship between it and other classes.
post class does not have postID.
please help me.
|
|
|
|
|
http://stackoverflow.com/questions/20001995/code-first-entity-framework-and-foreign-keys[^]
have a read of the above, from what I can work out the generic forgein keys are automatically worked out by the framework as long as the names and types are the same. But if you want to specify the forgein key by data annotation then you will have to do something like
[ForeignKey("Move_ID")]
Movie Movie{ get; set; }
the full example is in the stackoverflow question.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
I have five classes :
1.post :parent
2. and 3 sub class :article,news.advertisement
3.tags
.
How can I craate relation between 3 sub class and Tags.
each class :article ,news,advertisement has 0 or many tags .
please help me.
my code is:
public abstract class Post
{
protected string Title { get; set; }
protected string Content { get; set; }
protected DateTime AddDate { get; set; }
protected bool IsReady { get; set; }
public virtual Member Member { get; set; }
[ForeignKey("Member")]
public int MemberID { get; set; }
[DefaultValue(0)]
public int Views { get; set; }
public ICollection<Tag> Tags { get; set; }
public ICollection<Comment> Comments { get; set; }
}
public class Article:Post
{
[Key]
public int ArticleId { get; set; }
public IList<Tag> Tags { get; set; }
}
public sealed class Tag
{
[Key]
public int TagId { get; set; }
public string Value { get; set; }
}
public class News : Post
{
[Key]
public int NewsId { get; set; }
public IList<Tag> Tags { get; set; }
}
modified 3-Feb-15 12:05pm.
|
|
|
|
|
Hi all
I am completely new to programming and C# but have been given a project which seems fairly difficult to me.
The project involves recreating the WW2 Enigma Machine cipher in a C# Windows Form. The machine has 3 rotors which contain all letters of the alphabet in a set order. These rotors turn one place on each use of the machine.
To allow for the rotors to turn, I have created a .txt file for each which has the 26 possible rotor settings. I will include a small example below...
EKMFLGDQVZNTOWYHXUSPAIBRCJ
KMFLGDQVZNTOWYHXUSPAIBRCJE
MFLGDQVZNTOWYHXUSPAIBRCJEK
FLGDQVZNTOWYHXUSPAIBRCJEKM
LGDQVZNTOWYHXUSPAIBRCJEKMF
The problem I am having is that I am unsure on how to read this file, only take the required line, and then be able to look at each character in order to carry out the cipher. i THINK I need to read the whole text into a string, grab another string from that using the first 26 characters (or until the new line), then separate the characters from there. Maybe....
If anyone could point me in the right direction I would hugely appreciate it. It is also very possible that I am looking at the situation in the wrong way, so any help would be great.
Thanks
Tetra1044
|
|
|
|
|
Depends on the exact organisation of your .txt file: if it has newlines between as rotor setting as you show in the example, then it's easy:
string[] rotorSettings = File.ReadAllLines(pathToFile);
If it doesn't, then you have options: you can read the whole file as a string and "chop out" the section you want with a substring:
string allSettings = File.ReadAllText(pathToFile);
string myRotor = allSettings.Substring(zerobasedIndexOfRotor * lengthOfSetting, lengthOfSetting);
Or if you are only interested in the characters in a rotor settign individually, then just access teh characters directly:
string allSettings = File.ReadAllText(pathToFile);
char first = allSettings[zerobasedIndexOfRotor * lengthOfSetting + 0];
char second = allSettings[zerobasedIndexOfRotor * lengthOfSetting + 1];
...
If there a lot of settings and you don't want to read them all, then create a Stream, and use Seek to locate the start of each setting in turn.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thanks for the quick response Griff, I'll give that a go now
|
|
|
|