spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
  Home » C# » Page 1
Why @Using doesnt find PageList namespace
In controller using PagedList; using PagedList.MVC; In view @model PagedList.IPagedList<YourModel> @using PagedList; @using PagedList.MVC; Paging @Html.PagedListPager(Model, page => Url.Action("Index", new { page = page })) Rebuild solution and it should work.

Categories : C#

HTTPContext not finding client CAC cert in ASP.NET and iis express
I don't know if this helps or not, but in IIS integrated mode HttpContext is not populated until after the HttpApplication.Start event is complete. If you have your offending code too early in the application lifecycle, these values won't exist. This makes sense if you think about it because you wouldn't want the whole application to be initialized under a specific user's context. So to access yo

Categories : C#

Why does my Kendo Grid for ASP.NET MVC fail with large data over network?
I never needed to adjust any jsonSerialization config settings.. To your @(Html.Kendo().Grid<Production>() add... .Scrollable(scrollable => scrollable.Virtual(true)) You can use that with paging, etc...thus @(Html.Kendo().Grid<Production>() .Name("Production") .Scrollable(scrollable => scrollable.Virtual(true)) .Columns(c => { c.Bound(p => p.DateProce

Categories : C#

windows phone Image Translation (movement/animation)
I believe this article should answer all your questions: Quickstart: Animations for Windows Phone While you can use the RenderTransform in order to position objects relative to where the layouting engine puts them the easier way is to place the Control you want to move around inside a Canvas which directly attaches position properties to that Control. This is shown in one of the samples in the ar

Categories : C#

What is the proper way to designate the data context and bind hierarchical data in the treeview?
You seem to be very confused. You're trying to data bind to your ServiceView.Services property, so what is the ServiceCollectionViewModel class for? The sole purpose of a view model is to provide all of the data (and functionality) required for its view. Now we can go different routes... it all depends what you actually want. If you want to data bind from outside the UserControl to the ServiceVi

Categories : C#

Serialize Json string to object caseinsensitive
It looks like you have a Group class. Assuming it looks something like this: public class Group { public int Id { get; set; } public string State { get; set; } public string Override { get; set; } public int LightOutput { get; set; } public string GroupName { get; set; } } you could just deserialize your array directly into a List<Group>: var groups = JsonConvert.

Categories : C#

Why am I unable to use the setter method of a base class in a derived class
You need either an assignment call or another method to call setName. How is the compiler supposed to know when to execute this method call? Do this: public class Car : Vehicle { public string SetCarName() { base.setName(); } }

Categories : C#

Mac OS X, C#/Mono - GeckoFX "System.DllNotFoundException: xul"
Firstly, to my knowledge no one has ever run geckofx on OSX. The problem you are seeing is probably easy fixable but before getting geckofx to work on mac you will likely hit more problems. Geckofx's architecture on Windows is simple. The GeckoWebBrowser control is a winforms based control, which underneath are win32 controls and gecko/firefox on windows also uses win32 controls. However on Lin

Categories : C#

MVC3 Database entities don't get initialized as expected
Make sure you are using the Initialization strategy which matches what you are trying to achieve. Database.SetInitializer<T>(...); By having the line below in your App_Start method, I believe you may be bypassing initialization Database.SetInitializer<SpaceUpEntities>(null); Here are some options from an article on code first database initialization strategies that I hope will be

Categories : C#

Linq insert statement will not work
using (var northwind = new DataClassesDataContext()) { var newSupplier = new Supplier(); //SupplierID = northwind.Suppliers.Max(id => id.SupplierID) + 1, newSupplier.CompanyName = "Doe Electrical"; newSupplier.ContactName = "John Doe"; newSupplier.ContactTitle = "Mr."; newSupplier.

Categories : C#

How can I keep a row highlighted even when i select another row. C# datagridview
I must admit that I'm not happy with this solution because there is a short blink, but at least it selects the way you want: List<DataGridViewRow> selectedRows = new List<DataGridViewRow>(); void selectRows() { dataGridView1.SuspendLayout(); foreach (DataGridViewRow r in dataGridView1.Rows) r.Selected = selectedRows.Contains(r); dataGridView1.ResumeLayout();

Categories : C#

SQLite .db file is not being removed/renamed even after closing the connection of that particular file
One of the things I learned programming with SQLite is that closing the connection is simply not good enough. You need to wrap everything in a using block. Make sure your SQLiteConnection object is wrapped in a using block, your SQLiteCommand is wrapped in a using block and your SQLiteDataReader is wrapped in a using block. Your code should look similar to this: using (var connection = new SQLite

Categories : C#

How to create Xap file
Silverlight Apps create .xap files, for Universal Apps (like the one you created) a .appx file will be created instead. Perhaps it is called .appxupload. Those packages reside in the subfolder AppPackages inside your project. So if you take that file you will be fine. The store accepts those as well. The App will only support WP8.1 however. If you need help in creating the .appx packages using V

Categories : C#

Entity Framework Error: Specified Include Path Is Not Valid for Virtual Entity
Thanks Ben... Your property is called SiteSettingOption (no s) but you are trying to Include("SiteSettingOptions") (notice the final s). Remove the last s. You can avoid this by using the Include extension that uses lambdas rather than strings this would be something like Include(x => x.SiteSettingOption)

Categories : C#

How to make a custom tool tip template in WPF XAML
I've gone some way to answering this question. The following style is defined for ToolTip: <Style TargetType="ToolTip"> <Setter Property="OverridesDefaultStyle" Value="True" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ToolTip"> <Border Background="GhostWhite" BorderBrush="Gainsboro" Bord

Categories : C#

Does .NET promote Int32 to Int64 for arithmetics on 64-bit architectures?
Actually, CLR doesn't do anything: C# compiler does. You see, CLR does support Byte and Int16 types, however it does not support arithmetic operations on them, so to perform arithmetic operations on Byte and Int16, they initially should be transformed to smallest supported type (Int32). Behavior of this transformation is dependent on language. C# team choosed to automatically convert all computat

Categories : C#

How to get a List of Integers from a Property when another property exists within a List?
Sounds fairly straightforward, unless Ive misunderstood the question var matched = _SubCategories.Where(sc => _ParentCategoryIDs.Contains(sc.ParentID)) .Select(sc => sc.ID) .ToList(); Then you can join this with pipes: var result = String.Join("|",matched);

Categories : C#

Connect to Bluetooth Device with ouit modifying the Manifest file
It's definitely possible to connect several bluetooth devices, however not without changing the Manifest. If you don't specify your device id's or services in there, the OS will not give you the capability to connect them through Bluetooth.Rfcomm or Bluetooth.Gatt.

Categories : C#

Specify mapping expression - so that it works with LINQ EF and Projection
Have you tried ValueResolver<TSource, TDestination> ? A simple example (string id to mongodb objectid): public class UserIdResolver : ValueResolver<UserViewModel, ObjectId> { protected override ObjectId ResolveCore(UserViewModel source) { ObjectId objectId = new ObjectId(); if (!string.IsNullOrEmpty(source.Id)) { objectId = new ObjectId(so

Categories : C#

Conditionally change row color on GridView
You don't need to loop through the table, the values for the cells in the row are given to you in the even arguments. if (e.Row.RowType == DataControlRowType.DataRow) { //Change the number here to refer to the column you are checking if(string.IsNullOrEmpty(e.Row.Cells[1].Text)) { e.Row.BackColor = Color.Gray; } } However, as pointed out by @im1dermike in the comments, i

Categories : C#

Dynamics CRM - Get Entitiy Query results as Datasource for Repeater
When binding is set to Repeater1.DataSource = result.Entities; you should change template code to: <%#Eval("Attributes["hs_firstname"]")%> Alternatively you can use: <%#((Entity)Container.DataItem).Attributes["hs_firstname"]%>

Categories : C#

Is a read-only HashSet inherently threadsafe?
Yes, it is. As long as the construction of the HashSet object is thread safe, accessing it will always be thread safe as long as the contents doesn't change. If you initialize the Lazy using LazyThreadSafetyMode.PublicationOnly you can be sure the initialization of the Lazy is thread safe. When multiple threads try to initialize a Lazy<T> instance simultaneously, all threads are allowed

Categories : C#

Error 1 Cannot initialize object of type 'System.Drawing.Point[]' with a collection initializer
Collection initializers only works on collections that have an Add method; since arrays have a fixed length, there is no add method, so they can't be used like that. However you can do this instead: Locations = new[] { new Point(60, 20), new Point(10, 10), },

Categories : C#

RowDetailsTemplate ItemSource Binded to an EF NavigationProperty
In order to achieve that you must also specify the DataContext in inner DataGrid or get the inner DataGrid Navigation property collection directly from the Main DataGrid using the ElementName, the following code work perfectly : <DataGrid x:Name="DataGrid" Style="{StaticResource DataGridStyle}" AutoGenerateColumns="False" EnableRowVirtualization="True" ItemsSource="{Binding ListPersons}" Sel

Categories : C#

Mocking DbContext for TDD Repository
You need to mock out the Set<T>() call. Something like this should work out. // Arrange var context = new Mock<Context>(); var set = new Mock<DbSet<User>>(); context.Setup(c => c.Set<User>()).Returns(set.Object); // Act // Assert set.Verify(s => s.Add(It.IsAny<User>()), Times.Once()); You don't really need to make verify anything except that Add() w

Categories : C#

Mutual Authentication(2- Way SSL Autentication in c#)
Actually you can use the WCF libraries also in a console application. So you should be able to reuse your existing code. If you really want do it without WCF, there are examples out there on how to use ssl Client certificates in C#: http://www.example-code.com/csharp/https_upload_with_cert.asp

Categories : C#

.net WCF, change namespace prefixes in WSDL file
the solution is here http://www.codehosting.net/blog/BlogEngine/post/Custom-wsdl-from-WCF.aspx you can write own wsdl and change stuff in there

Categories : C#

Find objects from an IEnumerable List
You could try OfType<T>: IEnumerable<TextBox> textboxes = myEnumerable.OfType<TextBox>();

Categories : C#

Group a Datatable and copy to another table C#
Don't be afraid to use loops ;) var nameGroups = dtMain.AsEnumerable().GroupBy(row => row.Field<string>("Name")); foreach (var nameGroup in nameGroups) { bool isFirstRow = true; foreach (DataRow row in nameGroup) { DataRow newRow = dtFinal.Rows.Add(); newRow.SetField("Name", isFirstRow ? nameGroup.Key : ""); newRow.SetField("Plot", row.Field<int>

Categories : C#

Fast desktop image capture
Perhaps you can access the screen buffers at a lower level of code and hook directly into the layers and regions Windows uses as part of its screen updates. It sounds like you are after the raw display changes and Windows already has to keep track of this data. Just offering a direction for you to pursue while you find someone more knowledgeable.

Categories : C#

Inserting a decimal into sql cause inserting a zero number Instead of a decimal number near zero
If you are using EF 4.1 or above override the OnModelCreating method and specify Precision for decimal column in EF. See (Decimal precision and scale in EF Code First) post. public class EFDbContext : DbContext { protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder) { modelBuilder.Entity<Class1>().Property(object => object.Rate).HasPrecision

Categories : C#

EF6.1 not loading other entity in many-to-many relationship
In your example that "works" EF is just populating the properties because it has them in it's local cache, however this is not the way to do what you need. You either need to explicitly include Bazs.Bar in your query as below which will eager load them. var foo = Set<Foo>().Include("Bazs.Bar").Single(f => f.Id == Id); Alternatively if you declare your navigation properties as virtual

Categories : C#

UserManager.DeleteUser Specified method is not supported
In ASP.NET Identity v1, DeleteAsync was not supported. Based on the error message you are seeing, it looks like you are referencing v1. Try updating your ASP.NET Identity packages to v2.1.0 via Nuget.

Categories : C#

C# Mysql Link Combobox with Database values in textboxes
I would set a static value that you know exists in the database inside the query and see if it returns anything. This will tell you if your query is incorrect. string Query = "SELECT * FROM dark_heresy.talents WHERE TalentName='This.Guy';"; As per your second question, you can create static global variables inside your Required_Attributes form like: public static string username; public stat

Categories : C#

EF Code First - How do you specify foreign key name for child object table used by different type of parents
imho, what you want, from a relational database point of view, is a column (Option.FieldId) being a foreign key to 2 tables DropDownField and RadioButtonField. That is whenever you insert an option, FieldId must reference an existing DropDownField AND an existing RadioButtonField. That is at least weird. I don't think this can/should be achieved.

Categories : C#

Problems trying to return the view with an API controller
An API controller is a controller which provides a RESTful response. You cannot return a view from it. Instead of doing that, consider returning a response (values) which forces the client that asks for an action to redirect to another controller (passing arguments if necessary) to return a view. Your case does not look like you need an API; in this case just try this (change what you inherit):

Categories : C#

How to work around EF generating SQL statement nested too deeply
may be public static List<Hierarchy> Select(List<int> selection) { var result = context.Hierarchy .Where(sub => sub.Children.Any(csub => selection.Contains(csub.Id))); }

Categories : C#

LinkButton not sending the correct CommandArgument to code behind
The problem is that you're using string filename = Path.GetFileName(filePath); for each file you want to add. What happens is that you're adding "something.pdf" to the list. What will happen when you click on the download button is that it will try and get the "something.pdf" from the relative path. Which in this case is without the "/test/" folder. What you can do is to change the followi

Categories : C#

How to raise PropertyChanged event for child properties?
You should databind to the property name TaxonomyID. Assuming your BindingSource.DataSource is pointing to CurrentTaxonomy class. tbTitle.DataBindings.Add("Text", _currentTaxonomy, "TaxonomyID", false, DataSourceUpdateMode.OnPropertyChanged); See this post: C# DataBinding - automatically writing changed property to label or textbox

Categories : C#


Recently Add
C# call abstract method from static method
Why @Using doesnt find PageList namespace
HTTPContext not finding client CAC cert in ASP.NET and iis express
Why does my Kendo Grid for ASP.NET MVC fail with large data over network?
windows phone Image Translation (movement/animation)
What is the proper way to designate the data context and bind hierarchical data in the treeview?
Serialize Json string to object caseinsensitive
Why am I unable to use the setter method of a base class in a derived class
Mac OS X, C#/Mono - GeckoFX "System.DllNotFoundException: xul"
MVC3 Database entities don't get initialized as expected
Linq insert statement will not work
How can I keep a row highlighted even when i select another row. C# datagridview
SQLite .db file is not being removed/renamed even after closing the connection of that particular file
How to create Xap file
Entity Framework Error: Specified Include Path Is Not Valid for Virtual Entity
How to make a custom tool tip template in WPF XAML
Does .NET promote Int32 to Int64 for arithmetics on 64-bit architectures?
How to get a List of Integers from a Property when another property exists within a List?
Connect to Bluetooth Device with ouit modifying the Manifest file
Specify mapping expression - so that it works with LINQ EF and Projection
Conditionally change row color on GridView
Dynamics CRM - Get Entitiy Query results as Datasource for Repeater
Is a read-only HashSet inherently threadsafe?
Error 1 Cannot initialize object of type 'System.Drawing.Point[]' with a collection initializer
RowDetailsTemplate ItemSource Binded to an EF NavigationProperty
Mocking DbContext for TDD Repository
Mutual Authentication(2- Way SSL Autentication in c#)
.net WCF, change namespace prefixes in WSDL file
Find objects from an IEnumerable List
Group a Datatable and copy to another table C#
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.