|
Create two versions of your program using conditional compilation - you can use #if PAIDVERSION ... #endif to keep the features you want people to pay for to yourself and your paying customers.
Anything else can be broken, usually quite easily - but if the features aren't there at all, then it obviously can't be "cracked".
Well - it's just a thought ...
Regards
Espen Harlinn
|
|
|
|
|
This is the approach I would use. I'm typically writing custom software for individual clients so this doesn't really apply to my work, but is definitely the approach I would use for a commercial product.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
|
Really thanks for the support everyone.Making two types of apps inside one msi(exe),Is that so professional?
Well,doesn't matter.Still i have a doubt.I thought of storing two ,three variables inside the app by making the settings strings in application properties in Visual Studio.
In VB ,you can simply write 'If(My.Settings == "0")
But how to do that in C#.There is now "my" in there...
|
|
|
|
|
>> Is that so professional?
No - create two different setup projects too, one for the demo, and one for the paying customers
>> 'If(My.Settings == "0")
Oh my, that's not what I proposed. The VB syntax would be
#If PAIDVERSION Then
stuff only available to paying customers
#End If
If you use something like If(My.Settings == "0") everything gets compiled into the executable. The idea was to totally remove those features from the demo version - that way nobody can "crack" your licensing scheme.
>> But how to do that in C#.There is now "my" in there...
in C# you have "this" - a reference to the instance of the current object - and it's also used for .Net extension methods
|
|
|
|
|
I am pretty much happy about the way you helped me.
using the keyword 'this' as in if(this.setting == 0)
{
app.run(TRIAL)
}
Is not at all working.I don't prefer buying an app.but its not so personal.we need to use it as they want it be.One person in Code Project
(Hameed Ji) made an application like this.it was pretty helpful and easy to understand.but still its disabling the whole application that needs to be registered.
>> a reference to the instance of the current object - and it's also used for .Net extension methods.
If you can please give a any example over CP or any where else.
|
|
|
|
|
Sir,
i want to create an application to compress image in c# and save it in a database usually sql server.
|
|
|
|
|
Other then bmp, all popular formats (jpg, png) are already compressed and can't be compressed again. Then just store it as a varbinary(max) column.
-- Modified Friday, February 25, 2011 12:32 PM
|
|
|
|
|
Hello,
I realize that, DatabaseContext class generated by LINQ to SQL / LINQ to ENTITY should not be a part of the Views and so I want to encapsulate the uses of DatabaseContext classes within my Data Access Layer. So, when I need to display a set of records in a GridView in Windows Form, I can simply let my Data Access Layer return the List<Person> of the records and display that records in GridView without any problem. Great!
Here is my Person class
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
Ok, now, I face the big problem when I need to save the changes back to the database. I may have 1000 records displaying in the Grid view where the GridView is bound to a BindingSource. My user can change only 2-3 records from the GridView and delete some of the records as well. How can I tell the LINQ to SQL / LINQ to Entity (data context) about the changed records so that when I pass the List<Person> object to my Data Access Layer, Data Access Layer can identify which records needs to be updated and finally the Data Context updates those records ?
Can you please show me some pattern for this problem ?
Regards.
|
|
|
|
|
Well, see, the smarter option is not to allow editing in a grid. Have a form that displays and allows updates to one record and if the user clicks the "Save" button, that one record gets saved to the database.
|
|
|
|
|
I see ! So, if I want to expose an Excel Spreadsheet like facility to my User, I cannot follow n tier pattern thats sad. But anyway, thank you for giving me the idea.
|
|
|
|
|
Nadia Monalisa wrote: expose an Excel Spreadsheet like facility
That is rarely a good idea, it's not very user-friendly, but this may be one of those rare times, just be sure, ask potential users for their opinion.
|
|
|
|
|
You need some kind of mapper to map the data properly. After making the changes on the grid, get the currently available Person instances from grid's datasource and compare it against the list that you load from database. You will need some unique identifier on the Person type which can be used to find out the proper domain object. Given the two lists, you can do a diff and find out newly added, updated and deleted records.
Best wishes,
Navaneeth
|
|
|
|
|
Thanks for your reply.
Sounds like a lots of tasks, moreover maintenance can be nightmare if I keep changing my domain model and database table fields. I thought, if I implement INotifyPropertyChanged in my Business Object (Person Class) then, the .NET Framework can notify a data context about dirty rows automatically. I tried and that did not work. Looks like, I will have to compromise either Excel / Spreadsheet functionality or Decoupling of Presentation Layer + Data Access Layer (LINQ to SQL DataContext class)
|
|
|
|
|
Nadia Monalisa wrote: Sounds like a lots of tasks,
Not actually. You have all the information, you just need to match with proper objects. And finding diff, a single line LINQ can do it.
Best wishes,
Navaneeth
|
|
|
|
|
Thank you for showing the light. I will give a try. I just missed the idea about using LINQ to find the diff. now feeling easy
|
|
|
|
|
HOw about a couple of extra properties on your Person Class.
bool IsUpdated;
bool IsDeleted;
Your grid needs to be filtered to omit the IsDeleted items (or just highlight them in some way so the user can change their minds)
Set the IsUpdated when anything is, erm, updated.
Then your DAL just updates where IsUpated, and deletes where IsDeleted.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
Thank you for your reply. Actually I intended to use a boolean property 'IsDirty' for a dirty row. But, In order to set this 'IsDirty' property, I will need to write code which may not look clean and maintainable. I may need to handle some events of the GridView to set this IsDirty property. It can be more messy if i want to maintain IsDeleted property as well.
But, I thought, INotifyPropertyChanged interface was invented for solving this problem. Am I wrong ? When I see some demo videos about Silverlight / WPF, I see the instructor is implementing INotifyPropertyChanged interface on business objects and tracking is being taken care by the framework.
Moreover, when working with Silverlight, I am forced to use Business Objects instead of direct database access, as Silverlight is a client side tech. So, the framwork is offering solution for Silverlight !
Am I missing anything about it ?
|
|
|
|
|
Ok, i am having a really harsh times trying to figure this out. Basically, i am trying to create a simple database - really simple task but i am failing over and over again and all this MSSQL thing seems to me like some kind of dark black evil magic
So here is the scenario (OS is Vista and server is sqlexpres 2005). First off, to eliminate error 5 (access denied) for it to be able to save .mdf and .ldf files in my application current directory, i had to launch mssql server under Local System account (it was running as Network Service first) - i got no idea if this is correct fix though. Ok, here we go. Here is my code for creating new DB:
private void CreateDatabase(String ConnectionString, String Query)
{
if (String.IsNullOrEmpty(ConnectionString) ||
String.IsNullOrEmpty(Query))
{
return;
}
else
{
using (SqlConnection conn = new SqlConnection(ConnectionString))
{
try
{
if (conn.State != ConnectionState.Open)
conn.Open();
SqlCommand cmd = new SqlCommand(Query, conn);
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show("ERROR: " + ex.Message);
}
finally
{
conn.Close();
}
}
}
}
Connection string is simple: server = CSRSS-PC\SQLEXPRESS, Integrated Security = True, database = master.
I am using windows auth, not sqlserver auth. And query is simple too:
String sql = "CREATE DATABASE aaaaa ON PRIMARY"
+"(Name=aaaaa_DB, filename = 'C:\\Users\\csrss\\Documents\\Visual Studio 2008\\Projects\\mssql\\mssql\\bin\\Debug\\aaaaa.mdf', size=3,"
+"maxsize=5, filegrowth=10%)log on"
+"(name=aaaaa_log, filename='C:\\Users\\csrss\\Documents\\Visual Studio 2008\\Projects\\mssql\\mssql\\bin\\Debug\\aaaaa_log.ldf',size=3,"
+"maxsize=20,filegrowth=1)";
While server was running as Network Service - this code was returning this error 5 (access denied).
Now, when i have restarted server as well as writer as well as reader under Local System account - now it can create files in my app dir, but here goes next thing. I got this button for running the above code. So i click it and observe. Indeed, these 2 files (db and log) suddenly appeared in folder, but application stopped responding. Ok, i am waiting. After, like, 5 seconds, db and log files disappeared, and application gives me this exception:
Cannot obtain exclusive lock on 'model', try again later. And the funniest thing, btw, here is a function i wrote for fetching databases:
public static String[] GetDatabases(String ConnectionString, Boolean extra)
{
List<String> l = new List<string>();
String[] output = null;
if (String.IsNullOrEmpty(ConnectionString))
{
return new String[] { "ERROR: Empty connection string!" };
}
else
{
DataTable dbs = null;
using (SqlConnection conn = new SqlConnection(ConnectionString))
{
if (conn.State != ConnectionState.Open) conn.Open();
try
{
dbs = conn.GetSchema(extra ? "tables" : "databases");
}
catch (Exception ex)
{
conn.Close();
return new String[] { ex.Message };
}
finally
{
conn.Close();
}
foreach (DataRow dr in dbs.Rows)
{
l.Add(dr[extra ? "table_name" : "database_name"].ToString());
}
}
output = l.ToArray();
}
return output;
}
So, now if first i will not call a function for obtaining databases, and i call a function for creation of new database, i got exception that server is unreachable, or there is no sql server running on my PC, or something like that. Only after i call "GetDatabases", i can call "CreateDatabase", which gives me exception that it cannot obtain lock and i got no other connections to sql server so what is wrong with this lock? What is wrong with this code? This is some kind of an horror working with this mssql thing
Thanks for any help in advance.
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
Ok, solved it myself. The first issue appeared because i forgot to initialize connection string. Whatever.
Next issue, with this exclusive lock, you will never find such explanation in google, lol.
So, the answer is so simple, if you bounded a datagridview to sql table (or in reverse) there appears an extra something, which is called .Net sql client data provider, and this beautiful data provider locks database model. How i love all these C# adapters and providers, gosh...
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
As far as your problems in using SqlExpress as a Network Service are concerned, take a look at this[^] thread on MSDN.Social. Scroll down to the answer from Tommy123456 .
I also suspect that your database creation problems might also be caused by a 'permissions' problem (on the file system, this time), although as I am still running XP I cannot be more explicit about Vista.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
|
|
|
|
|
Thanks, that was informative. However, first issue is directory access related - Network Service has the lowest rights (in case of writing data anywhere) and i dont have time to mess with configuration and granting access to it everywhere, and it is not that important.
Second issue was that exactly what i have pointed out - i forgot that i have bound a mssql table to a dataset, basically, this query solved the issue:
select spid ,PROGRAM_NAME from master..sysprocesses where DB_NAME(dbid) = 'model'
so when its bound, sql data provider locks database; if database 'model' locked - new database cannot be created, as you know. Kids stuff, yet sometimes mind goes blur and you just stuck with it. Anyway, solved.
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
Hi all,
i need to sort a listview based on the item tag property (as a category)
in fact, the listview is populated with a folder content from windows explorer.
when i click on the column header, i need to sort by name the folders and the after the files
Example :
the desired result
MyFolder
YourFolder
MyFile
YourFile
instead of
MyFile
MyFolder
YourFile
YourFolder
thanks for any idea, snippet code or a link
best regards
Fady Sayegh
|
|
|
|
|
The ListView class has, oh surprise, a Sort method. It offers a default sorting order, however it also provides a custom sorting order. MSDN holds the essential information, and one of my articles (see link in sig) deals with sorting in general, it does not mention ListView in particular.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi Luc,
thanks for your quick answer.
can you please provide me the link to your article.
sorry but i have clicked on the link [My Articles] but i didn't find any article about sorting issues
can you please redirect me to the right url.
thanks again for your help
Best regards
Fady Sayegh
|
|
|
|
|