|
55/5000
if I use two dlls? Again I have the same problem. Think of a programmer or business who sells dlls (my case) and sells more than one to the same client.
in this case, from Main I can reference the global space of the first dll (not a good solution), but from the second dll I can not. I do not know how to refer from dlls to a common global space from Main, because I can not do without the global variables since many functions use them constantly. Seriously c# does not have a global space and Microsoft closes the topic with a brief patch That does not solve this problem? Can not be.
modified 4-Jan-17 12:24pm.
|
|
|
|
|
The only solution to this issue is to remove the duplicated code from your application. You may even need to rethink your design.
|
|
|
|
|
I'm wondering if I can compile the two dlls with the reference to Cls_Common.cs and from main do something like (if possible):
Name_Common.Cls_Common.StCommon = new global::Name_Common.St_Common();
And when I have to call the dlls do something like:
Name_Encrypt.Cls_Encrypt.StCommon = (Name_Common.St_Common)Name_Common.Cls_Common.StCommon
Help, thank you.
|
|
|
|
|
That does not sound right. It seems to me that you are trying to make things much more complicated than they need to be with this. Whatever purpose this class serves, you can only have it in one place, either in the DLL or in the EXE part, not in both.
|
|
|
|
|
I have many functions that use global variables. I need to access a common space from the dlls and Main. Is it too much to ask? Does not C# do? We are not going well.
|
|
|
|
|
Regequion wrote: Is it too much to ask? No, not at all. But you do need to get the design right, and work within the rules of what is possible and allowed. And, most of all, what is logical.
|
|
|
|
|
I don't see why you can't just create a "Common.dll" (in the "MyApp.Common" namespace, for example), that contains singletons or statics for your "shared" data and methods.
As long as this dll does not reference other dll's "higher up" (to avoid circular references), then there should be no problem "sharing".
|
|
|
|
|
how to store the value selection on calendar in database
|
|
|
|
|
There is a lot left for us to assume. Can you share these details so you can get a better response:
- Is this Windows Forms, WPF, ASP.Net WebForm, MVC, something else?
- Which database are you using (not really relevant though)?
- Have you tried anything yet?
- If 3 is a yes, post the code, tell us what is error/exception you get.
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
I am trying to retreive data from a webpage with a label saying "export". The data is partially showing on the screen, if I manually click on "export" a window comes up and ask to save, save as, or cancel. I then save all data to my computer as a csv file. However when trying to get the data using c# I get the code behind "export" and not the data, code starts out as "".
I am using the following code:
WebClient webClient = new WebClient();
webClient.UseDefaultCredentials = false;
webClient.Credentials = new NetworkCredential(strUsername, strPassword);
webClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
webClient.DownloadFile(url, @strOutputFile);
*note url is for "export".
Can someone please point me in the right direction.
Any help will be greatly appreciated.
Thanks in advance.
Michael
modified 3-Jan-17 20:49pm.
|
|
|
|
|
Are you trying to get the page HTML or some specific data from it?
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
I am trying to get the csv file full of data not the html code.
|
|
|
|
|
OK, and I assume the URL in the DownloadFile method ends with CSV. Is that correct?
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
|
One thing might be happening here is that the website expects you to reach to file from the page where the button is. Can you add appropriate (that page's URL) referrer header to your request and check?
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
The following is the website:
"http://finviz.com/screener.ashx?v=150&ft=4" however you have to pay for the service to get data, which will be "http://elite.finviz.com/screener.ashx?v=150&ft=4".
Find the button export the url on that is "http://elite.finviz.com/export.ashx?v=150&ft=4"
This is the actual url I use then add or don't add ".csv".
if I enter the url in my browsers command line, the file is downloaded, but when I use c# I get html code.
|
|
|
|
|
Can anybody else possibly help with this.
Thanks in advance,
Michael
|
|
|
|
|
What is the exact URI that you are using for the download?
|
|
|
|
|
I solved the problem with help from the website, I needed to add authorization into the url.
Thanks,
Michael
modified 5-Jan-17 9:18am.
|
|
|
|
|
I have created app that converts text to speech but whatever gender I select it speaks same voice!!!
SpeechSynthesizer ss;
private void Form1_Load(object sender, EventArgs e)
{
ss = new SpeechSynthesizer();
}
private void button1_Click(object sender, EventArgs e)
{
ss.Rate = SpeedTrackBar.Value;
ss.Volume = VolumeTrackBar.Value;
try
{
switch (comboBox1.SelectedIndex)
{
case 0:
ss.SelectVoiceByHints(VoiceGender.NotSet);
break;
case 1:
ss.SelectVoiceByHints(VoiceGender.Male);
break;
case 2:
ss.SelectVoiceByHints(VoiceGender.Female);
break;
case 3:
ss.SelectVoiceByHints(VoiceGender.Neutral);
break;
default:
break;
}
ss.SpeakAsync(textBox1.Text);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button2_Click(object sender, EventArgs e)
{
ss.Pause();
}
private void button3_Click(object sender, EventArgs e)
{
ss.Resume();
}
private void button4_Click(object sender, EventArgs e)
{
SpeechSynthesizer ss = new SpeechSynthesizer();
ss.Rate = SpeedTrackBar.Value;
ss.Volume = VolumeTrackBar.Value;
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Wave Files| *.wav";
sfd.ShowDialog();
ss.SetOutputToWaveFile(sfd.FileName);
ss.Speak(textBox1.Text);
ss.SetOutputToDefaultAudioDevice();
MessageBox.Show("Recording Completed..", "T2S");
}
|
|
|
|
|
You have a global variable speachsynthesizer (ss) that you configure on button1 then on the actual record button4 you create a new LOCAL variable speachsynthesizer of the same name (ss) that you do not configure but use that to speak the text.
|
|
|
|
|
The Record button is used to save text inside textBox!
I have replaced varibles from button1 and button4 with SpeechSynthesizer ss = new SpeechSynthesizer(); as global varible but still not working!!!!
|
|
|
|
|
|
If you now have two lines like this in your code, that's not correct. You only need to declare it once, in the Form_Load. So, you have a member variable called ss (that's a poor choice for a name - why not just call it speechSynthesizer), and in your Form_Load you have ss = new SpeechSynthesizer . That's it - that's the only place you should see the new Synthesizer() call.
This space for rent
|
|
|
|
|
Exactly. That's a bug in the language specification of C# which can cause bugs in the software which are very hard to find. Fortunately, ReSharper can issue a warning. And a well designed style guide should suggest different styles for fields vs. local variables.
|
|
|
|