|
I tried your instruction using ADO, and it works..
Thank you very much.
But I want to show you the main reason of my problem, I was using sp_attach_single_file_db
but this instruction attach the database to SQL just if you have already attached it then deattached it !
But if you use this command to attach database for the first time to SQL it thow an exception
Thank you Mr.PIEBALDconsult you were helpful.
|
|
|
|
|
|
Hi to all,
I have made a set up of a project which use some dll files.When I install the setup with version say 1.0, it is installed properly.
I have another set up of same project but this updated say 2.0
Now I nstall 2.0 without uninstalling 1.0 to the same path(path of 1.0).
2.0 replace the 1.0 but those dll files are not replacing, still there are dll files of 1.0 are present.
Please guide me how to solve the problem.
Thanks in adv.
|
|
|
|
|
Have you ensured the assembly versions are being updated in the AssemblyInfo.cs file?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks for ur replay.
I have changed the version in AssemblyInfo.cs.
Let me tell what are the versions-
Initially there was 1.0.0.0 version and then I changed it to 1.0.3.0.
Please can u tell me what settings we do in installer so that older overwrites the new.
|
|
|
|
|
I just had a similar problem.
Get Orca, a program which is part of the Microsoft SDK.
Open your .msi installer file in Orca.
Select properties from the left hand side.
Insert a new row into the table:
- Property: REINSTALLMODE
- Value: amus
This will cause your installer to overwrite previous versions when installing.
Remember for each release that you need to update the Version property for the Setup project, which (in VS 2008) will prompt you to create a new ProductCode GUID.
|
|
|
|
|
Hi,
I'm looking for the (class / property / etc) naming rules in c#. I thought 'surely the language specification must have them' and 'surely Google can tell me', problem is I keep finding naming conventions etc etc.
I need the RULES, e.g. You may not start a property name with a number. The stuff that makes the compiler break...
I don't care about upper case vs lower case etc, those are conventions...
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
|
Hi, thanks for your reply but I am not looking for design patterns (I am familiar with a vast array of them already), I'm looking for a definitive list of rules for naming in c#
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
Ah, i thought design patterns would be ah good basis how to name classes at least. Sorry if my answer couldn't help you.
|
|
|
|
|
You might find the ECMA Spec for C# useful. It's available here[^].
|
|
|
|
|
Another alternative is on MSDN[^]
I are Troll
|
|
|
|
|
See section 2.4.2 Identifiers of the CSharp Language Specification available from MSDN at http://msdn.microsoft.com/en-us/library/ms228593.aspx[^]
Generally speaking, identifiers must start with a letter or underscore and can follow with almost any unicode character. If the identifier is a keyword, it must be prefixed with an '@' character.
|
|
|
|
|
dear all
float nwidth = (ImageBW8 .Width / ImageBW8.ImageWidth);
float nheight =((ImageBW8 .Height / ImageBW8.ImageHeight);
ImageBW8 .Width ,ImageBW8.ImageWidth,
ImageBW8 .Height ,ImageBW8.ImageHeight, all got value, but however nwidth and nheight are 0.0. anyone can help me? why nwidth and nheight are only 0.0, instead of exact values there. thanks a lot.
|
|
|
|
|
Hi, maybe like this:
float nwidth = Convert.ToSingle(ImageBW8.Width) / Convert.ToSingle(ImageBW8.ImageWidth);
float nheight = Convert.ToSingle(ImageBW8.Height) / Convert.ToSingle(ImageBW8.ImageHeight);
|
|
|
|
|
Hi,
You can try :
float nwidth = (float)ImageBW8.Width / (float)ImageBW8.ImageWidth;
float nheight = (float)ImageBW8.Height / (float)ImageBW8.ImageHeight;
|
|
|
|
|
if those properties are integers, you get integer division.
And if 0 < Width < ImageWidth , you would get zero for nwidth.
You assigning the quotient to a float variable does not influence how an expression gets evaluated.
|
|
|
|
|
I’m apparently trying to do something stupid, because the C# help file says that I can’t, and that usually means my design is all jacked up.
Here’s a version of what I’m trying to do:
I have a base class, ItemBase, and I want to give it the method
public class ItemBase
{
public abstract static List<string> GetAvaliableUpgrades();
}
Then, I have three classes
public class Car : ItemBase { }
public class Van : ItemBase { }
public class Truck : ItemBase { }
(they implement GetAvaliableUpgrades())
And finally, I have a control
public class MyItemDisplay<T> : UserControl where T : ItemBase
{
public void SetUpgrades()
{
foreach (string s in T.GetAvaliableUpgrades())
listBox1.Items.Add(s);
}
}
Now I know that I can’t do that in C#, but I’m wondering if there is another way to implement this type of process. Since the Upgrades List is a property of the class itself and not unique to each instance, I want to make the GetAvaliableUpgrades() method static, and I don’t want to repeat myself, so I want the SetUpgrades() method in the Control to work on any ItemBase.
I know I can make something similar work by doing:
public class ItemBase
{
protected abstract List<string> GetMyUpgrades();
public static List<string> GetAvaliableUpgrades<T>() where T : ItemBase, new()
{
T item = new T();
return item.GetMyUpgrades();
}
}
public class MyItemDisplay<T> : UserControl where T : ItemBase
{
public void SetUpgrades()
{
foreach (string s in ItemBase.GetAvaliableUpgrades<T>())
listBox1.Items.Add(s);
}
}
But that feels sloppy and incorrect, since I’ve got to make an instance of a class to get a property about that class. Is there some kind of design pattern I can research that will allow me to get the kind of functionality that I’m looking for in C#? Or is there another way to allow me to have one control that works on a family of classes, without having to copy-paste a bunch of code? Thank you all in advance for your time!
Matt
|
|
|
|
|
Right, statics can't be polymorphic so they can't be abstract.
How will you get the upgrades? Are they plug-ins? Maybe you need an upgrade manager class?
|
|
|
|
|
I was going to have each class that : ItemBase have it hard coded, or maybe load from a file. My ultimate goal is to be able to create class AnyNewItem : ItemBase that I can just drop in to my program and will work with MyItemDisplay<T> : UserControl where T : ItemBase without me having to modify MyItemDisplay<T>.
Again, I could make the GetAvaliableUpgrades() non-static, but it doesn't feel right since the Upgrades are a propery of the class itself and not any specific instance.
Any ideas? =/
Thanks in advance,
Matt
|
|
|
|
|
I wonder if having Car, Van, Truck (etc.?) as distinct C# types is the root of the problem.
What would be the pros & cons of having a simple Vehicle class (and, probably, you would no longer need an ItemBase class)?
Here's how I might implement Vehicle:
public enum VehicleType { Car, Van, Truck }
class Vehicle
{
public VehicleType VehicleType { get; set; }
static private readonly Dictionary<VehicleType, List<string>> _availableUpgrades = new Dictionary<VehicleType, List<string>>();
public static List<string> GetAvailableUpgrades(VehicleType vehicleType)
{
if (!_availableUpgrades.ContainsKey(vehicleType))
throw new ArgumentException("Vehicle type " + vehicleType + " not recognized in upgrades collection.");
return _availableUpgrades[vehicleType];
}
}
If you absolutely must have distinct classes for each vehicle type, perhaps this would work:
class ItemBase
{
static private readonly Dictionary<Type, List<string>> _availableUpgrades = new Dictionary<Type, List<string>>();
public List<string> GetAvailableUpgrades()
{
Type myType = GetType();
if (!_availableUpgrades.ContainsKey(myType))
throw new ArgumentException("Vehicle type " + myType.Name + " not recognized in upgrades collection.");
return _availableUpgrades[myType];
}
}
class Car : ItemBase
{
}
|
|
|
|
|
public class MyItemDisplay<T> : UserControl where T : ItemBase{
public T ItemBase{
get;
set;
}
}
|
|
|
|
|
Hello!
Today i try write my own Music Player in C# - winmm.dll, but I don't know, how to go to next song, when last is end.
My Aplication:
Button1. Load music.
Button2. Add address from textBox, to listbox.
Button3. Stop playing.
And all work, when i add my music to playlist, and click on selected address, music start. But:
- How i can go to next song, when last end?. Because now, when song is end, player no start play next song.
Eg:
Music1
Music2
Music3
Music4
Eg.
- When I click on Music2 it starts to play, but then wants go to the next song when Music2 end - in this case Music3.
- When I click on Music1 it starts to play, but then wants go to the next song when Music1 end - in this case Music2.
etc... Easy Play list...
&&
When Music4 end, player must go to first song! In this case - Music1!
This is my code:
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
using System.Runtime.InteropServices;<br />
<br />
namespace WindowsFormsApplication1<br />
{<br />
public partial class Form1 : Form<br />
{<br />
[DllImport("winmm.dll")]<br />
private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
if (openFileDialog1.ShowDialog() == DialogResult.OK)<br />
{<br />
textBox1.Text = openFileDialog1.FileName;<br />
}<br />
}<br />
<br />
private void button2_Click(object sender, EventArgs e)<br />
{<br />
listBox1.Items.Add(textBox1.Text);<br />
}<br />
<br />
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)<br />
{<br />
mciSendString("close MediaFile", null, 0, IntPtr.Zero);<br />
mciSendString("open \"" + listBox1.Items[listBox1.SelectedIndex].ToString() + "\" type mpegvideo alias MediaFile", null, 0, IntPtr.Zero);<br />
mciSendString("play MediaFile", null, 0, IntPtr.Zero);<br />
<br />
}<br />
<br />
private void button3_Click(object sender, EventArgs e)<br />
{<br />
mciSendString("close MediaFile", null, 0, IntPtr.Zero);<br />
}<br />
<br />
}<br />
}<br />
Please help!
modified on Monday, August 30, 2010 8:00 PM
|
|
|
|
|
It seems you want a notification when the current song is finished. I guess it is in the documentation somewhere, however things could be very simple: have a look at this CodeProject article Using mciSendString to play media files[^], I'm pretty sure it holds what you need.
|
|
|
|
|
Thanks for answer
Yep, i read this tutorial but i no have problem with playing (Its work for me), but with playlist. Idk how make going to the next song. )
Eg.
In listBox have:
C:/Music/Blablabla.mp3
C:/Music/Blablabla2.mp3
C:/Music/Blablabla3.mp3
And i want:
C:/Music/Blablabla.mp3 started.... Song.... End.
Now my program: Play song... When song end, make nothing.
I want when:
C:/Music/Blablabla.mp3 when song is end, go to
C:/Music/Blablabla2.mp3. When C:/Music/Blablabla2.mp3 end go to: C:/Music/Blablabla3.mp3. When C:/Music/Blablabla3.mp3 end, go to: C:/Music/Blablabla.mp3 (First song)
Etc
|
|
|
|
|