|
|
|
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
|
|
|
|
|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Worked great, thanks again!
|
|
|
|
|
What an interesting assignment !
The pictures I've seen of the Engima machines that used rotors with alpha-numeric characters all show A~Z; I'm curious why your "sample" doesn't suggest that alpha-numeric order.
«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
modified 4-Feb-15 12:32pm.
|
|
|
|
|
The outside appearance of the rotors do show A-Z, but the wiring inside connects the letters to completely different letters.
So using a 5-letter example...
ABCDE would be shown on the outside, but the wires could be connecting...
DCAEB. Then on the next rotation, A = C, then A = A, A = E, etc.
So in the sample above I'm plotting the possible connections with A-Z. My thinking is that I will convert a user's keyboard input to a number 0-25, which can then be used to grab the correct ciphered letter from an array
|
|
|
|
|
I'm working on a web project and I need to do the following. I want to run different cmdlets on a VMM server (https://technet.microsoft.com/en-us/library/dn246490.aspx).
Right now when I need to run a cmdlet I open a runspace, connect to the VMM server using this cmdlet:
https://technet.microsoft.com/library/jj613273%28v=sc.20%29.aspx and then disconnect.
The problem is that disconnect doesn't work as expected and so I have memory leaks.
The solution is to use one connection to the server,using the previous cmdlet, and then perform all other actions via this connection (on new runspaces).
So I need to share the fact that I'm connected on each new runspace I open. I suppose I should use the RunspacePool class and maybe the InitialSessionState member but I'm not sure.
Thanks for your help!
ps: http://stackoverflow.com/questions/28254778/how-to-share-a-server-connection-between-different-powershell-runspaces-in-c-sha[^]
|
|
|
|
|
Does this have anything to do with C#?
|
|
|
|
|
Of course.Runspaces and code is running in C# using System.Management.Automation.
Thanks for replying!
|
|
|
|