|
|
Oh boy, haven't you ever done an installation via commandline?
Try this in a Console ("DOS") Window (running elevated!):
msiexec /i "%SOURCE%" /quiet /passive ALLUSERS=1 TARGETDIR="%TARGET%" /l*v "%LOGFILE%"
Replace %SOURCE% with your source package (C:\....\yourpackage.msi),
%TARGET% with the installation target (E:\SomeFolder), and
%LOGFILE% with the place where you want to see the installation logs (C:\Temp\install.log).
When you got it working, call that command from your C# application.
|
|
|
|
|
Okay, first off i would like to say i have already looked this question over myself before asking, with that being said i get errors as an outcome.
I'm trying to convert a (open source) library to a portable class library so i can use the library in my Windows 8 App Development since Windows 8 App Development doesn't support Class Library's. The problem is for some reason i get errors like this:
http://prntscr.com/3wlw2a[^]
...And YES, i do have "using System.Runtime.InteropServices;" at the top.
http://prntscr.com/3wlwp5[^]
http://prntscr.com/3wlww2[^]
For anyone wondering, I'm trying to convert this: https://ps3lib.codeplex.com/releases/view/108287[^]
My Skype: MichealWeston7
My Youtube: www.youtube.com/user/CODNoobFriendly
|
|
|
|
|
You get this error because a Portable Class Library does not support DllImport. When you think about it, you can see why this would be the case - the whole point of PCLs is that they can be used across platforms, but what you are trying to do is very much platform specific, you don't get the same DLLs on a Windows Phone that you do on a Windows desktop box.
|
|
|
|
|
Okay thanks for the response! But even without DllImport, would it still be possible to go about it a different way? -I feel so close, but yet so far away.
Also, (if it came down to it) couldn't I just go about it by P-Invoking it through the default class library (.dll) through the WIN8 Application i'm making?
My Skype: MichealWeston7
My Youtube: CODNoobFriendly
|
|
|
|
|
Looking at the fact you're trying to do marshalling as well as importing DLLs, I don't see how you're easily going to achieve this. What you might have to do is drop down from your PCL into a platform specific part here.
|
|
|
|
|
Well, thank you for trying to help... Really i appreciate it, but i figured out a workaround without needing to convert the source to a portable library. Thanks.
[(KINDA) SOLVED]
(KINDA) Solution:
What i did...
I used the source from PS3Lib and put all of the classes in my Windows 8 Application, took out all references regarding TMAPI/TMAPI.dll/TMAPI_NET.cs entirely. CCAPI ONLY Compatible PS3Lib (Which is okay, as portable apps assentially wouldn't be able to execute ProDG TargetManager or the ProDebugger on they're phone.), CCAPI.dll only calls.
Since the Portable Class Library doesn't support use of [DllImport("PS3Lib.dll")]/etc, and import/use of CCAPI.dll the Windows 8 Application (C#/XAML) itself does... kinda a loophole in a way... Instead of converting a class-library to a portable-class-library for my APP i put the library within it manually with the classes(.cs) and the removal of TMAPI.
P.S. I still think TMAPI would be possible for [WINDOWS 8 APPS ONLY], but i don't really care to mess around too much with it as i don't see it going anywhere as CCAPI.dll & PS3Lib.dll will be more realistic.
Again thanks for all your help Pete O'Hanlon.
P.P.S. Like i said this is KINDA solved, it fixed my issue by going about programming it a different way, but still isn't THE solution if you know what i mean.
Skype: MichealWeston7
Youtube: www.youtube.com/user/CODNoobFriendly
modified 26-Jun-14 18:03pm.
|
|
|
|
|
I have a PDF Documnet that would like to extract Content from PDF and Chackbox and Radio Button types fields value. PDF file have a version 1.4(Acrobat 5.x) and may be genrated from web browser.
CheckBox appear such types in PDF
i want to find checked checkboxes value But no any API and tool is successfully parse to such types of Checkbox fields value and i just extract to text from PDF successfully. and checkboxes didn't recognize to Checked value by APIs.
If any one Knows how to extract and which API should work for such types of PDF files. Please suggest me.
Thanks in advance
|
|
|
|
|
HiGuys! I want to create my windows application from existing source code folder...and to have a database created from scratch and connected to microsoft sql server 2008 using visual studio 2008,how do I go about it?? ..thanx
modified 26-Jun-14 5:25am.
|
|
|
|
|
Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know.
And as for the task:
Start by specifying what you want to do.
Then design your system to the specification.
Create your DB and populate with sample data.
Code your design.
Test.
Repeat from the appropriate stage above until it works.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
And don't post a phone number either. That's even more stupid than posting your email address in a public forum. You realize you just posted your phone number so that billions of people can now see it, correct? That includes anyone who wants to call you up and sell you penis enlargement pills.
|
|
|
|
|
Missed that - and the repeat in his username!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Can I call you "collect"?
|
|
|
|
|
I am getting this Unable to cast object of type error for below code
var cityState = SplitValue(citiesStates[0]);
var customers = new List<customer>()
{
new Customer()
{
CustomerId = 1,
FirstName = "bikash",
LastName = "shrestha",
Email = "bikash@hotmail.com",
Address = "482 pacific hwy",
City = "Phoenix,AZ",
State = sortedStates.Where(state => state.Abbreviation == cityState[1]).SingleOrDefault(),
Zip = 85230,
Gender = Gender.Female
},
new Customer()
{
CustomerId = 2,
FirstName = "prakash",
LastName = "shrestha",
Email = "prakash@hotmail.com",
Address = "482 pacific hwy",
City = "Phoenix,AZ",
State = sortedStates.Where(state => state.Abbreviation == cityState[1]).SingleOrDefault(),
Zip = 85231,
Gender = Gender.Male
}
};
customers.ForEach(p => context.Customers.Add(p));
var companies = new List<company>()
{
new Company()
{
CompanyId = 1,
Name = "abc",
Email = "abc@hotmail.com",
Address = "xyz street",
City = cityState[0],
State = sortedStates.Where(state => state.Abbreviation == cityState[1]).SingleOrDefault(),
Zip = 2066,
Customers = new List<customer> { customers.Single(u => u.CustomerId == 1), customers.Single(u => u.CustomerId == 2) }
}
};
companies.ForEach(p => context.Companies.Add(p)); <-- here is the error.
context.SaveChanges();
My classes
----------
public class Company
{
public int CompanyId { get; set; }
[StringLength(50)]
public string Name { get; set; }
[StringLength(200)]
public string Address { get; set; }
[StringLength(500)]
public string Email { get; set; }
[StringLength(1000)]
public string Phone { get; set; }
[StringLength(50)]
public string City { get; set; }
public State State { get; set; }
public int StateId { get; set; }
public int Zip { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public virtual ICollection<customer> Customers { get; set; }
//public Company()
//{
// Customers = new HashSet<customer>();
//}
}
public class Customer
{
public int CustomerId { get; set; }
[StringLength(50)]
public string FirstName { get; set; }
[StringLength(50)]
public string LastName { get; set; }
[StringLength(100)]
public string Email { get; set; }
[StringLength(1000)]
public string Address { get; set; }
[StringLength(50)]
public string City { get; set; }
public State State { get; set; }
public int StateId { get; set; }
public virtual ICollection<company> Companies { get; set; }
public int Zip { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public Gender Gender { get; set; }
public ICollection<order> Orders { get; set; }
// public Customer()
//{
// Companies = new HashSet<company>();
//}
}
Please help. I am trying to do DataInitialization using Code first approach and having no luck.
|
|
|
|
|
Try adding the Customers, calling SaveChanges on the context, then add the Companies.
|
|
|
|
|
 I updated the code to be below: but still getting same error
Company company1 = new Company();
company1.CompanyId = 1;
company1.Name = "abc";
company1.Email = "abc@hotmail.com";
company1.Address = "xyz street";
company1.City = cityState[0];
company1.State = sortedStates.Where(state => state.Abbreviation == cityState[1]).SingleOrDefault();
company1.StateId = 1;
company1.Zip = 2066;
company1.Phone = "949494848";
company1.Customers = new List<Customer>();
Customer customer1 = new Customer();
customer1.CustomerId = 1;
customer1.FirstName = "bikash";
customer1.LastName = "shrestha";
customer1.Email = "bikash@hotmail.com";
customer1.Address = "482 pacific hwy";
customer1.City = "Phoenix,AZ";
customer1.State = sortedStates.Where(state => state.Abbreviation == cityState[1]).SingleOrDefault();
customer1.StateId = 1;
customer1.Zip = 85230;
customer1.Gender = Gender.Female;
customer1.Orders = new List<Order>();
Customer customer2 = new Customer();
customer2.CustomerId = 2;
customer2.FirstName = "prakash";
customer2.LastName = "shrestha";
customer2.Email = "prakash@hotmail.com";
customer2.Address = "482 pacific hwy";
customer2.City = "Phoenix,AZ";
customer2.State = sortedStates.Where(state => state.Abbreviation == cityState[1]).SingleOrDefault();
customer2.StateId = 2;
customer2.Zip = 85231;
customer2.Gender = Gender.Male;
customer2.Orders = new List<Order>();
Order order1 = new Order();
order1.Id = 1;
order1.CustomerId = 1;
order1.Product = "apple";
order1.Date = DateTime.Today;
order1.Price = 5;
order1.Quantity = 1;
Order order2 = new Order();
order2.Id = 2;
order2.CustomerId = 1;
order1.Product = "apple";
order2.Date = DateTime.Today;
order2.Price = 5;
order2.Quantity = 1;
customer1.Orders.Add(order1);
customer2.Orders.Add(order2);
company1.Customers.Add(customer1);
company1.Customers.Add(customer2);
using (var dbCtx = new CustomerManagerContext())
{
dbCtx.Companies.Add(company1); <-- here i get same error now.
dbCtx.SaveChanges();
}
The error details:
Unable to cast object of type 'System.Collections.Generic.List`1[CustomerManager.Model.Customer]' to type 'CustomerManager.Model.Customer'.
|
|
|
|
|
OK, now you changed the original post so that there are order. Same problem. Create records for a single table at a time then save the changes.
Create the Companies first and save them, then add Orders and save them.
|
|
|
|
|
could you please help me?
If I first save company first it will be as below
using (var dbCtx = new CustomerManagerContext())
{
dbCtx.Companies.Add(company1);
dbCtx.SaveChanges();
}
company1.Customers.Add(customer1);
company1.Customers.Add(customer2);
customer1.Orders.Add(order1);
customer2.Orders.Add(order2);
how do I now save customer1, customer2 and order1 and order2 using the context?
|
|
|
|
|
I do have a requirement for you when writing code: USE YOUR BRAIN!
Serisously? What's preventing you from putting the other creation objects in the same "using" context? NOTHING! You can call SaveChanges multiple times before disposing the CustomerManagerContext.
So, create your Customers, SaveChanges. Create your Companies, SaveChanges. Create your Orders, SaveChanges, ...
See a pattern there?
|
|
|
|
|
Ok. I did as per you mentioned but I get below error now
using (var dbCtx = new CustomerManagerContext())
{
dbCtx.Customers.Add(customer1);
dbCtx.SaveChanges();
dbCtx.Customers.Add(customer2);
dbCtx.SaveChanges();
dbCtx.Companies.Add(company1);
dbCtx.SaveChanges();
dbCtx.Orders.Add(order1);
dbCtx.SaveChanges();
dbCtx.Orders.Add(order2);
dbCtx.SaveChanges();
}
Entities in 'CustomerManagerContext.Customers' participate in the 'Customer_Companies' relationship. 0 related 'Customer_Companies_Target' were found. 1 'Customer_Companies_Target' is expected.
this is because I have below method
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Customer>().
HasMany(c => c.Companies).
WithMany(p => p.Customers).
Map(
m =>
{
m.MapLeftKey("CustomerId");
m.MapRightKey("CompanyId");
m.ToTable("CustomerCompany");
});
modelBuilder.Entity<Company>().HasRequired(c => c.Customers).WithMany().WillCascadeOnDelete(false);
modelBuilder.Entity<Customer>().HasRequired(c => c.Companies).WithMany().WillCascadeOnDelete(false);
base.OnModelCreating(modelBuilder);
}
sorry still learning entity framework.
|
|
|
|
|
Please remove that OnModelCreating. It's pretty broken; it would require that a customer exist before a company does, and that a company exist before a customer does....
|
|
|
|
|
Okay, you have a little work to do on this. even when using POCOs, you need to keep the shape of the database and the limitations of SQL (like field values in tables) in mind. You still use foreign keys to map to complex types, and you cannot insert values into a SQL field that it does not recognize as a native type.
I'm assuming your context class looks like:
public class MyContext : DbContext
{
public DbSet<Customer> Customers { get; set; }
public DbSet<Company> Companies { get; set; }
public DbSet<Order> Orders { get; set; }
}
You have a M:M mapping for customers to companies, and and 1:M for customers and orders (I'm guessing). without seeing the Order class, it looks like our base structure has an few inherent flaws, and will not be able to normalize or even perform proper data access at the moment.
Here's the obvious changes:
public class Company
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Display(AutoGenerateField = false)]
public int CompanyId { get; set; }
[StringLength(50)]
public string Name { get; set; }
[StringLength(200)]
public string Address { get; set; }
[StringLength(500)]
public string Email { get; set; }
[StringLength(1000)]
public string Phone { get; set; }
[StringLength(50)]
public string City { get; set; }
public State State { get; set; }
public int StateId { get; set; }
public int Zip { get; set; }
public virtual ICollection Orders{ get; set; }
}
public class Customer
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Display(AutoGenerateField = false)]
public int CustomerId { get; set; }
[StringLength(50)]
public string FirstName { get; set; }
[StringLength(50)]
public string LastName { get; set; }
[StringLength(100)]
public string Email { get; set; }
[StringLength(1000)]
public string Address { get; set; }
[StringLength(50)]
public string City { get; set; }
public int Zip { get; set; }
[Display(AutoGenerateField = false), ForeignKey("State")]
public int StateId { get; set; }
public virtual State State { get; set; }
public virtual ICollection Orders{ get; set; }
public string Gender { get; set; }
Okay, now that the changes are made to those classes, let's look at a possible Orders class. I'll just add the fields to wire the M:M up, I don't know what other fields you have in there. This is assuming that One Customer can have Many Orders, and One Company can have Many Orders, but each Order has only One Customer and only One Company.
public class Order
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Display(AutoGenerateField = false)]
public int Id { get; set; }
[Display(AutoGenerateField = false), ForeignKey("Customer")]
public int CustomerId { get; set; }
[Display(AutoGenerateField = false), ForeignKey("Company")]
public int CompanyId { get; set; }
public virtual Customer Customer { get; set; }
public virtual Company Company { get; set; }
public Order(){}
public Order(Customer customer, Company company)
{
CustomerId = customer.CustomerId;
CompanyId = company.CompanyId;
}
}
My sample has a parametrized constructor, but that's optional. If you do include one, though, always include a default constructor.
Now let's swing back to the Context class and implement an Update method.
public class MyContext : DbContext
{
public DbSet<Customer> Customers { get; set; }
public DbSet<Company> Companies { get; set; }
public DbSet<Order> Orders { get; set; }
public bool UpdateOrder(Order order)
{
if(Orders.Any(x => x.Id == order.Id))
this.Entry(order).State = EntityState.Modified;
else
Orders.Add(order);
return this.SaveChanges() != 0;
}
public bool UpdateCompany(Company company)
{
if(Companies.Any(x => x.CompanyId == company.CompanyId))
this.Entry(company).State = EntityState.Modified;
else
Companies.Add(company);
return this.SaveChanges() != 0;
}
public bool UpdateCustomer(Customer customer)
{
if(Customers.Any(x => x.CustomerId == customer.CustomerId))
this.Entry(customer).State = EntityState.Modified;
else
Customers.Add(customer);
return this.SaveChanges() != 0;
}
public bool DeleteOrder(Order order)
{
if(Orders.Any(x => x.Id == order.Id))
{
Orders.Remove(order);
return this.SaveChanges() != 0;
}
return false;
}
}
Then just create objects and add them via context.Update().
modified 25-Jun-14 10:11am.
|
|
|
|
|
Hi, thanks for the detailed explaination. In my case, a company can have many customer and a customer can belong to many companies. only customers will have order. Sorry to call this "order". It should actually be called "Job". Would I require making any changes to what you have described above for my situation?
|
|
|
|
|
Hi guys,
I'm new to VB6 and also MSMQ. I went through a lot of tutorials online but seems like there is no solution for my question.
I managed to sending from C# to C# or VB6 to VB6 but not from VB6 to C# or vice versa. So I wonder is it a way to do that or there is no way to do this kind of communication.
For example: I want to send this to MSMQ
Dim PropBag As PropertyBag
Set PropBag = New PropertyBag
PropBag.WriteProperty "Customer", "Bob"
PropBag.WriteProperty "Product", "MoeHairSuit"
PropBag.WriteProperty "Quantity", 4
and get the details in C#, there is "Invalid character in the given encoding. Line 1, position 1." error when I use XmlMessageFormatter
Message mes = mq.Receive(new TimeSpan(0, 0, 3));
mes.Formatter = new XmlMessageFormatter(new String[] { "System.String,mscorlib" });
result = mes.Body.ToString();
I also tried to read from the stream but it come out with a weird symbol in my string. Below is the code and this is the output "늓\0\0\b\b휖ꭑ(\0customer\0Bob\0\b\a劑틠4\0product\v\0MoeHairSuit\b調⫳ᄂ.quantity\0"
Message mes;
mes = mq.Receive(new TimeSpan(0, 0, 3));
mes.BodyStream.Position = 0;
byte[] b = new byte[mes.BodyStream.Length];
mes.BodyStream.Read(b, 0, (int)mes.BodyStream.Length);
UnicodeEncoding uniCoder = new UnicodeEncoding();
result = uniCoder.GetString(b);
I get this exception "Cannot deserialize the message passed as an argument. Cannot recognize the serialization format." when using ActiveXMessageFormatter like below
mes = mq.Receive(new TimeSpan(0, 0, 3));
mes.Formatter = new ActiveXMessageFormatter();
result = mes.Body.ToString();
Do you guys have any idea how to do that?
Thanks in advanced 
modified 25-Jun-14 5:32am.
|
|
|
|
|
I haven't done any work in VB6 in quite a long time, but I would suspect that you can't use a PropertyBag to do this.
Why are you using VB6 at all since it's been dead for quite a while now?
|
|
|
|
|