|
Hello.
i want to make a project to take some references (*.dll) and to use the functions within, but to make the user to specify the location and the name, and set the namespace after i read the data from the user, until then the project doesn't know about that reference.
i wonder if a class exist and how can i use it to solve my problem.
Thank you.
regards,
metalsandman.
|
|
|
|
|
|
I have an application which required me to write some custom controls, so i placed them into dll files to make it easier to re-use. The problem is i want to deploy the application but i dont want my dll files exposed with the application, is there a way to hide the dll's or incorporate them in with the application executable similar to what Borland Builder does?
|
|
|
|
|
Hello all!
I am going to try to explain my problem as best as i can, please forgive my bad english.
Its like this, i am developing an application for handling scanned images and converting them to PDF. So far i have manged to do both of those things.
But i have a problem with saving the PDF file on a place of my choice.
As default the PDF file is saved in the bin folder. Now i know i can just write in the path where I want the file to be saved but I want to make it more dynamic.
I have simple text file containing the searchpath where the file should be saved, and i read it in to my application with the help of StreamReader. The searchpath is then read in to a string variable. Here is where the problem occurs. The string only returns null insted of the searchpath.
You can see my code below:
using System;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
namespace doc2PDF
{
///
/// Summary description for pdf.
///
public class pdf
{
public pdf(string imageFileName)
{
string search ;
FileStream bFile = new FileStream("start.txt",FileMode.OpenOrCreate);
StreamReader test = new StreamReader(bFile);
search = test.ReadLine();
// step 1: creation of a document-object
Document document = new Document();
try
{
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter writer = PdfWriter.getInstance(document, new FileStream(search, FileMode.Create));// its here that i want the searchpath to appear(search,FileMode.Create)
writer.setEncryption(PdfWriter.STRENGTH128BITS,"elvir","elvir",PdfWriter.AllowCopy);
// step 3: we open the document
document.Open();
// step 4: we add content to the document
PdfContentByte cb = writer.DirectContent;
Image image = Image.getInstance(new System.Drawing.Bitmap(imageFileName), System.Drawing.Imaging.ImageFormat.Png);
image.setAbsolutePosition(0,0);
image.Alignment = Image.MIDDLE;
image.scaleAbsolute(600, 800);
cb.addImage(image);
}
catch(DocumentException de)
{
Console.WriteLine(de.Message);
}
catch(IOException ioe)
{
Console.WriteLine(ioe.Message);
}
// step 5: we close the document
test.Close();
document.Close();
}
}
}
iTextsharp is the PDFlibrary that I use to make PDF files.
Any help is appriciated.
Thanks in advance
|
|
|
|
|
It looks like the line:
FileStream bFile = new FileStream ("start.txt",FileMode.OpenOrCreate);
is creating a new file rather than opening your "start.txt" file. Try specifying the path to start.txt like this:
FileStream bFile = new FileStream ("c:\\start.txt",FileMode.OpenOrCreate);
Then place "start.txt" in the root of drive C.
Hope that helps.
|
|
|
|
|
Hello
I'm trying to make a Dns query against ordb.org (a database contaning smtp servers that are classified as open relays).
I know that ordb.org wants the ipaddress for the smtp server with the octets reversed but that's not the problem.
I've been trying to construct a udp packet to send the information to the database but I can't get it right. I don't recieve an answer and i'm unsure if I'm attacking the problem from the right angle so to speak. Below is a rough code example on how I've been trying solve the problem.
/*Send question*/
Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
byte[] data = Encoding.ASCII.GetBytes(ReversedSMTPIP);
IPAddress addr = Dns.GetHostByName("relays.ordb.org").AddressList[0];
IPEndPoint dest = new IPEndPoint(addr,53);
client.SendTo(data,(EndPoint)dest);
/*Recieve answer*/
byte[] msg = new byte [32*1024];
IPEndPoint iend = new IPEndPoint(IPAddress.Any,0);
EndPoint end = (EndPoint)iend;
int lenght = client.ReceiveFrom(msg,ref end);
string answer = Encoding.ASCII.GetString(msg);
Below is the information from ordb.org FAQ which I'm having trouble understanding correctly.
The simplest way to get started using the ORDB to protect your mail relay against theft of service by spammers, is to arrange for it to make a DNS query agains relays.ordb.org whenever you receive an incoming mail message from a host whose relaying status you do not know.
The theory of operation is simple. Given a host address in its dotted-quad form, reverse the octets and check for the existence of an ``A RR'' at that node under the relays.ordb.org node. So if you get an SMTP session from [192.89.123.5] you would check for the existence of:
5.123.89.192.relays.ordb.org. IN A 127.0.0.2
We chose to use an ``A RR'' because that's what most MTA's can use to filter incoming connections. The choice of [127.0.0.2] as the target address was arbitary but will not change. As it happens, we supply a bogus ORDB entry for [127.0.0.2] so that mail transport developers have something to test against.
I'm on the right track here?
Any help at all would be greatly appriciated.
Best Regards
Kristofer
|
|
|
|
|
I think you need a send a full DNS query, instead of just the reversed SMTP IP. You need to form an actual DNS query and in the place of the domain name, use 5.123.89.192.relays.ordb.org or whatever.
The DNS query has a definite structure, which you can see here[^]
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Ok I read the RFC - 1035 and parts of RFC - 1034. I now understand it much better but how do I construct the packet?
As I understand it I have to create my own header and subparts of the query but how do I "type" the information and how do I delimit it?
Thanks for the help!
Regards
Kristofer
|
|
|
|
|
Hi,
im trying to capture the position of the mouse from the mouse move event and changing some properties. But the mouse move event doesnt seem to be fast enough to capture the movements immediately and change the properties accordingly!! Can anybody help regarding this?
Thanks and Regards,
Rajesh
|
|
|
|
|
In the mouse move event:
private void _MouseMove(sender,e)
{
Point p = Control.MousePosition;
//and then try to apply what you want according to the value of this point like:
this.Location = p;
}
|
|
|
|
|
Hi all
Please advice me how i can to change keyboard layout programatically in c#.
Thank.
|
|
|
|
|
Hello,
I have a data class in my Web Service server. Its name is User.
When I include this web service to the client and name it "WSA" the User class will be WSA.User.
the problem is when I serialize a User instance in client its type will be WSA.User and I can not deserialize it to a User instance in server. the types will be different.
What can I do?
|
|
|
|
|
Don't define User on both the client and server. Define User in a seperate dll, referenced by the service and client.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|
|
Do you mean that...
I should define a User dll on server. And both webservice and client should reference them??
I haven't experience of dlls. will it not be a problem for client to reference a dll in remote server?
|
|
|
|
|
Create a dll that contains the User class.
When you build the client, add a reference to the dll containing the user class.
When you build the service, add a reference to the dll containing the user class.
The client doesn't need to reference a remote dll, the user dll can be copied locally to both client and service.
This way, both the client and service will be using the same object.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|
|
Sorry, I'm a bigginer in C# , and i want to ask a trivial question , i get numbers from textBox as a string and i want to deal with it as an integr what i can do ?
misho
|
|
|
|
|
|
int n=Convert.ToInt32("123");
Check out all the Convert class static methods. Don't feel bad about not noticing this either--there's lots of these little hidden classes in .NET!
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
I would like to open, manipulate (zoom and pan) a pdf file in a c# web app. Is this ppossible? Any examples out there?
Brian
|
|
|
|
|
All you have to do is server up the PDR file, just like any other .JPG, .GIF, or .DOC file. The client will handle the rest provided Acrobat Reader is installed.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
lets say i have a simple form with a button on it. let button1_Click() be the function binded by the eventhandler delegate.
the problem: i need this function to do a certain task that may take some time. i don't want this to freeze the UI(user interface) however i need to stop any further calls to button1_Click() for the duration of the task. sounds realy easy but to my surprise it's not that easy.
take the following examples of the button1_Click function bodys:
<br />
{<br />
this.button1.Enabled=false;<br />
this.button1.Enabled=true;<br />
}<br />
visualy disables the button but if you push it (even if disabled) X times the function will execute exactely X times.
<br />
{<br />
if(this.ignore)<br />
return;<br />
this.ignore=true;<br />
this.ignore=false;<br />
}<br />
same as above just that it doesn't visualy disable the button.
ideas, solutions and explanations apreciated.
|
|
|
|
|
I think you should consider porting the task you wish to do on a separate thread. This will not "freeze" your GUI since it will be running on a separate thread, other than the main (GUI) one.
By doing this, you could also specify that you wish to wait for your thread-processing to complete before executing the rest of your code.
If you haven't implemented multiple threads before, then may I suggest to Google it. A simple google search for something like "C# Thread tutorial" or "C# Multithreading" will bring up tons of results.
Hope this helps
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
the problem is not the freeze of the GUI. that i can simply avoid by multithreading as you pointed out. the issue is stopping any further calls of the function during the execution of the task.
i have run into this problem when i had a task that needs like about 500 miliseconds to run (more exactely it's a MoveNext). i decided not to multythread it since it's quite short. the problem is when a users starts pounding the NextButton with 20 clicks a second (it happend to my by accident in a test) the application starts to slow down since it's ordered to do like 20 tasks/second and it can only do 2/second. not to mention sometimes it has to acces sensible data that has to be locked down for thread safety purposes and it sometimes takes like 2-5 minutes for it to actualy recover. there are more issues here like race conditions and so forth.
now i thought that blocking any calls to the function would be the easyest way to do it. however it turned out not to be.
|
|
|
|
|
Why don't you simply disable the button and enable it after the operation completes? Something like
private void buttonClick(object sender, EventArgs e)
{
thisButton.Enabled = false;
DoLongOperation();
thisButton.Enabled = true;
}
If you can't enable/disable, you can have a flag to simulate it, set the flag to false before the operation and reset it after the operation. The function would then first check if the flag is true before proceeding.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
obviously you haven't payed attention to my first post. the first example does just that. disabling the button and enabling it after the task is done. however it doesn't behave as expected. Visualy the button is disabled, but the function executes as many times as you push the button, regardless of it's state (disabled/enabled). if you put a counter in it and look at it after the test you'll see it's nice and neat the number of clicks you made.
i think that this is because somehow it stacks the events and fires them after the function executes. try and run this code:
<br />
public void task()<br />
{<br />
Thread.Sleep(1000);<br />
this.counter++;<br />
}<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
this.button1.Enabled=false;<br />
Thread t=new Thread(new ThreadStart(task));<br />
t.Start();<br />
while((t.ThreadState & (System.Threading.ThreadState.Stopped | System.Threading.ThreadState.Unstarted)) == 0)<br />
{<br />
Thread.Sleep(100);<br />
}<br />
t.Join();<br />
this.button1.Enabled=true;<br />
Debug.WriteLine(this.counter);<br />
}<br />
this has multi threading too. i can't exclude the possibility i'm doing something wrong but i can't seem to see where. pointers anyone?
|
|
|
|