DataContext not being inherited for DynamicResources in XBAP
Hi,
I was wondering if any one might know the answer to this. I am
attempting to apply the Model-View-ViewModel
pattern to my XBAP application. I created a UserControl(View) which is
created in a resource
(<views:MasterView x:Key="VIEW_Master" x:Shared="False" />). Th
resource is merged at this point into the
Application resources. The Master page sets its content to
{DynamicResource VIEW_Master}. The Master page
also sets its DataContext to a controller class. Before I put the
x:Shared = False in, every thing worked fine,
except if you refreshed the application (F5) it threw an exception.
The correct solution to this i found was to include
the x:Shared = False into the resource. As soon as i did that, all
data binding stopped working in the View.
After checking everything I released that the DataContext was no
longer inherited in the view, but when taking x:Shared = False out,
the DataContext is inherited. Does any one know why this happens and
possibly provide a solution for this?
Thanks,
Nick Tag: some computer langauages Tag: 138159
compact-framework textbox height
hi,
i'm porting an cf app from 1.1 to cf 2.0. i have a form, where i arrange
dynamicly
labels and textboxes at runtime.
my problem is now, that in cf 2.0 i cant' set the textboxes-heigth (in cf1.1
there was no problem). the textboxes are depending on the selected font and
as result, these textboxes are bigger (heigher ) on my form.
Is there a possibility to set this property in cf2 ?
thanks,
--
HolgerEb1 Tag: some computer langauages Tag: 138158
NET Regular Exp patterns work in VB6?
Hi, Will .NET Regular Exp patterns work in VB6? ex: reg exp pattern
for email in .net \w+([-+.']\w+)*@\w+([-.]\w+)*\=AD.\w+([-.]\w+)* Will
this work if i use it in vb6? Anybody has idea about it. Please
comment on this. Thanks, Thiru.S Tag: some computer langauages Tag: 138157
finding resourse leaks
My application appears to have a recourse leak. When the user starts
a background process, the handle count in Process Explorer (PE) goes
up by about 10, sometime 1 or 2 more, sometimes 1 or 2 less. When the
task is completed, there are somewhere between 4 and 7 handles still
open.
I am using an AutoResetEvent, but calling Close on it seems to have no
effect. I know in the unmanaged code I have to close thread handles
once I am finished with them, do I need to do something like that with
threads in the managed world?
I have gone through the code and it looks like I have all the lose
ends tied up now, are there any not so obvious objects which need to
be disposed? My process is loading images and shrinking them down. I
have checked the file objects, image objects, graphics objects and
everything is being disposed of once it is no longer needed.
Cartoper Tag: some computer langauages Tag: 138155
Compiling multiple win32 resources into an assembly
Hi,
I have a build process in which my .NET projects get compiled using a
common version resource which is compiled into a .RES file. My
project files import a shared MSBuild file which uses the
Win32Resource tag. eg:
(abbreviated for readability)
MyCommon.targets:
----------------
<PropertyGroup>
<Win32Resource>version.res</Win32Resource>
</PropertyGroup>
MyExe.csproj
------------
<PropertyGroup>
<ApplicationIcon>app.ico</ApplicationIcon>
</PropertyGroup>
<Import Project="MyCommon.targets" />
The problem is that when I try to build MyExe.csproj I get the
following error:
CSC : error CS1565: Conflicting options specified: Win32 resource
file; Win32 icon
because apparently Win32Resource and ApplicationIcon tags are mutually
exclusive. To get around this, I compiled the application icon into a
new .RES file and added it to the project using the Win32Resource
tag. eg:
MyExe.csproj
------------
<PropertyGroup>
<Win32Resource>app.res</Win32Resource>
</PropertyGroup>
<Import Project="MyCommon.targets" />
The build error goes away, the file is versioned correctly, but
there's no application icon -- the EXE has the generic icon. It looks
like the resource in MyCommon.targets overrides the one defined in my
executable project. If I remove the Win32Resource tag in
MyCommon.targets, then my EXE has the right icon, but then it doesn't
get versioned.
So my question is, how can I specify multiple Win32Resource tags? I'd
like to do something like
<PropertyGroup>
<Win32Resource>$(Win32Resource);version.res</Win32Resource>
</PropertyGroup>
...in MyCommon.targets to append to a list. BTW, I've tried that
syntax and it doesn't work. I get the following error:
CSC : fatal error CS2021: File name 'app.res;..\version.res' is
too long or invalid
Thanks,
CM Tag: some computer langauages Tag: 138152
Resource leak (handles count) in simple .NET application
Hi
I have a resource leak in the very simple project.
Project contains Form with one TextBox control in multiline mode.
After start this app I open Task Manager and see "Handles" count incremental
on every 1 second.
The source code is following:
public partial class Form1 : Form
{
System.Threading.Timer tm;
public Form1()
{
InitializeComponent();
// start timer 1 second interval ...
tm = new System.Threading.Timer(OnTimer, null, 0, 1000);
}
void OnTimer(Object state)
{
// add text in thread safe mode ...
AddTerminalText(" Resource Leak!!! ");
}
delegate void AddTextCallback(string text);
AddTextCallback d;
object[] arg = new object[1];
private void AddTerminalText(string text)
{
if (textBox1.InvokeRequired)
{
if (d == null)
{
d = new AddTextCallback(AddTerminalText);
}
arg[0] = text;
textBox1.Invoke(d, arg);
}
else
{
textBox1.AppendText(text); // add text into control
...
}
}
}
I don't understand what's wrong
Please help anybody !!!
Roman Tag: some computer langauages Tag: 138141
ClickOnce Deployment (BUG?)
Hello guys, There is an application (c# @ vs2005 SP1) that needs to be
deployed in a very controlled way.
ClickOnce was selected to do this task.
This application works over a database and, some times, this database needs
to be updated together with the code.
The problem is that not all the clients are in the same local network, so,
secondary servers were deployed using windows services to transfer the
information and to update and sign manifests, and then clients subscribe to
the local secondary server for updates.
Not all the clients have this advantage, several need to connect directly to
the primary server, so the updating process is slow and for this ClickOnce
has a great feature of download updates on the background.
This is done creating Download Groups and it works well. The problem is
that, when I download some files, I want to leave a small group at the
server for update at the moment the administrator decide.
That works ok, but when the app is closed and opened again, the application
asks the user if he/she wants to update the application because a new
download is available.
I'm sure that I unchecked the "The application should check for updates"
checkbox of the application updates dialog of the publish settings on the
project properties.
Is there any way to stop the window's display?
I think it's a bug!
Any ideas?
Thanks in advance.
FM. Tag: some computer langauages Tag: 138138
Is Sub Finalize Implicity Created on Classes?
Hi. Is Sub Finalize Implicity created at run-time by the CLR, even if you
(the programmer) don't explicity create a Sub Finalize method on the class?
Thanks Tag: some computer langauages Tag: 138133
Framework Registers/Stack restoration on exceptions
What does the framework for stack/registers restoration when an
exception is thrown ?
Is there any way to act on the stack before/after framework does it's
stack restoration ?
I currently know that .NET use the default exception handler with an
array of callback for catch blocks (at least 1.0 and 1.1), but if we
play with stack before an exception is thrown, Framework fails to
restore stack gracefully... Does anyone has an idea ? Tag: some computer langauages Tag: 138126
Is it a Copy or the acutal Object
Hello.
I'm uncertain about what Function A (below) receives from Function B, a copy
of the dataset or the actual dataset object:
Function FunctrionA () As Dataset
Dim ds as dataset = FunctionB()
'' What is "ds" at this point?
End Function
Function FunctionB() As Dataset
Using cn as New Connection ... to a database
Using ds as Dataset = ...stored procedure call
Return ds
End Using
End Using
End Function
Thanks in advance,
Mike Tag: some computer langauages Tag: 138124
.NET debugging environment crash
I am writing an app using C# for v2.0 of the framework. As I am still in
development, debug mode has been very helpful; however, I am experiencing an
IndexOutOfRange error that the environment is unable to catch. When it
occurs, the "debug" dialog pops up but clicking the button and then selecting
"Visual Studio 2005" fails to run VS properly. Instead, both processes (my
app and VS) crash with a message like "... failed to attach to crashing
process".
This is disconcerting as any and all other exceptions are properly caught
and, with the help of PDB files, located in the source code.
I do not use any outside DLLs. I compile all code in debug mode myself.
Any pointers as to what may be preventing the debugging environment from
handling this error? Tag: some computer langauages Tag: 138122
C:WINDOWS\system32\cmd.exe
tHi guys,
I have a black box continously flashing on and off the screen freezing
everything
error message reads
The syntax of the command is incorrect
I know nothing about the technical side of my lap top and before I spend a
lot of money getting this fixed can anyone out there tell me what this is and
how I can cure it. In English please and not computer speak.
Forever grateful Tag: some computer langauages Tag: 138119
How to show a ABOUT Form????????
How to show a ABOUT Form????????
Hello Everyone:
I use C# want to Create a Project. In my project. there are two
forms. One is main form, and another is a about form. In the about
form there are some information about my project. such as author's
information, product support and so on.
Now, I add a button in the main form, I want that if the user click
the button. It will show the about form . In button's event . the code
like this:
{
about.show();
}
but it doesn't work, if in Delphi. It will be work.
After that, I search the msdn. I know that there is a method called
AddOwnedForm(); so I coded the code like below:
{
Form cs =new Form();
this.AddOwnedForm (cs);
cs.Show();
}
This can show a new Form , but it is not the about form....
What I should do? I'm very sorry for my English , I 'm from China. Tag: some computer langauages Tag: 138118
Trading Forex
WHO WE ARE?
We are a partnership based in India and USA. We have a collective FOREX
trading experience of 4 years.We decided to start this venture with the
intent of helping people in India and other countries take advantage of
immense potential profits from the FOREX markets. We act as Liasons
between our clients and our partner forex broker and ensure that our
clients receive adequate support inspite of being in different
countries.
WHY CHOOSE US?
* FREE!! No extras commission spreads.
* Get a friendly advocate in USA in case of broker assistance.
* FREE assistance on forex related queries [Educational /Trading
Decisions /Trading Sysems /Regulations].
* Live Trading Chat facility to discuss live calls.
WHY INTERBANKFX?
* We have had excellent experience with InterbankFx.
* Professional Charting.
* MetaTrader Support.
* Credit Card deposit facility available.
* Minimum required to open an account as little as USD 250.
* No Dealing desk.
* Full hedging and trailing stops.
* Efficient spreads [as low as 2 on euro, subject to market
volatility].
--------------------------
<a href=http://www.eecpindia.com title=eecp>eecp</a>
<a href=http://www.anchorfx.com title=forex>forex</a>
<a href=http://indiaforex.eecpindia.com title=forex>forex</a>
*** Sent via Developersdex http://www.developersdex.com *** Tag: some computer langauages Tag: 138113
help on installation
Even more problems in that the system has now recognized 2.0 is uninstalled
but won't let me reinstall. Nor will it let me uninstall 1.1 and the
kb886903 hot fix. Any attempt tells me the installation package is
unavailable. Any suggestions?
Dej Tag: some computer langauages Tag: 138106
.net framework 2.0 installed?
After an automatic update to 3.0 the computer seems to think neither is
installed and yet won't let me reinstall or uninstall 2.0 and there is no
place for 3.0 to be uninstalled. Trying to install 3.5 tells me that 2.0a
is not installed. How can I fix this on an XP pro machine?
Thanks.
dej Tag: some computer langauages Tag: 138102
View options
I would appreciate some help. In a certain forlder I have, Windows XP keeps
insisting on giving aan ICONS view. I prefer the more compact LIST view in
the View menu. But despite repeated attempts to keep the view in LIST, every
time I open the folder I keep getting ICONS view. I saw no available option
or preference to set. Windows XP help was no help. Thanks Tag: some computer langauages Tag: 138098
WorkflowCompiler Error
I am using the WorkflowCompiler to compile xoml workflows at runtime into DLL
files. This has been working great, but lately after upgrading to .NET 3.5
(it seems - possibly this is unrelated) sporradically I get the following
error:
System.AccessViolationException: Attempted to read or write protected
memory. This is often an indication that other memory is corrupt. at
System.Workflow.ComponentModel.Compiler.WorkflowCompilerInternal.Compile(WorkflowCompilerParameters
parameters, String[] allFiles) at
System.Workflow.ComponentModel.Compiler.WorkflowCompiler.Compile(WorkflowCompilerParameters
parameters, String[] files) at
MaryKay.CRM.BusinessLayer.WorkflowUtil.CompileWorkflowXoml(String xoml) in
C:\Projects\FrontOffice\SAM-CRM\Current\Service
Interface\MaryKay.CRM.Services\WorkflowUtil.cs:line 127
This is inconsistent and nearly impossible to debug (since it appears to
happen inside the .NET Framework). We've rebooted the server, done other
things and nothing seems to consistently resolve the issue - it just comes
and goes.
If I don't hear back from anyone on the newsgroups, I'll open an incident
with Microsoft.
Thanks in advance for your help. Tag: some computer langauages Tag: 138097
ndp20-kb916002-x86.exe supperceded by .net 2 sp1?
When I tried to install patch ndp20-kb916002-x86.exe, I got message saying
"the program to be upgraded may be missing, or the upgrade patch may update
a different version of the program.". I wonder if this patch is supperceded
by some other patch, so I dont need to install it any more?
Thanks Tag: some computer langauages Tag: 138091
multithreading with WPF
I'm trying to understand how to speed up the ui. I have been experimenting
with background processing, but am not getting results that I think I should.
To experiment, I've created a window that contains a bunch of randomly sized
and placed circles. My goal is to be able to resize the window without it
hanging or being sluggish. To reduce the processing in the main thread, I've
created a BackgroundWorker thread to handle as much processing as I can.
Given the design, I believe that the windows sizing shouldn't be affected by
the value of numberOfPoints. I expect the update to be delayed, but the
resizing to be independent; however, that is not what I am getting.
Does anyone have any suggestions?
Also, I found that I was not able to freeze a VisualBrush after setting the
visual. Any suggestions on that?
Here's my sample code:
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
namespace FreezeTesting
{
class FreezeTesting
{
}
class DrawingPanel : Canvas
{
class WorkData
{
public Size Size { get; private set; }
public WorkData(Size s)
{
Size = s;
}
}
static Random r = new Random();
const int numberOfPoints = 1000;
bool vis = false;
BackgroundWorker bgworker = new BackgroundWorker();
public DrawingPanel()
{
Background = Brushes.White;
bgworker.WorkerSupportsCancellation = true;
bgworker.WorkerReportsProgress = true;
bgworker.DoWork += new DoWorkEventHandler(bgworker_DoWork);
bgworker.RunWorkerCompleted += new
RunWorkerCompletedEventHandler(bgworker_RunWorkerCompleted);
}
void bgworker_RunWorkerCompleted(object sender,
RunWorkerCompletedEventArgs e)
{
if (e.Cancelled == false)
{
VisualBrush vb = e.Result as VisualBrush;
if (vb != null)
{
Background = vb;
}
DrawingBrush db = e.Result as DrawingBrush;
if (db != null)
{
Background = db;
}
}
}
void bgworker_DoWork(object sender, DoWorkEventArgs e)
{
e.Result = null;
WorkData wd = e.Argument as WorkData;
if (wd != null)
{
if (vis)
{
DrawingVisual dv = new DrawingVisual();
using (DrawingContext dc = dv.RenderOpen())
{
for (int i = 0; i < numberOfPoints; i++)
{
int rad = r.Next(10) + 10;
dc.DrawEllipse(Brushes.Black, null, new
Point(r.NextDouble() * wd.Size.Width, r.NextDouble() * wd.Size.Height), rad,
rad);
if (e.Cancel == true)
return;
}
}
VisualBrush vb = new VisualBrush(dv);
vb.Freeze(); // throws an error... don't understand why
e.Result = vb;
}
else
{
GeometryGroup gg = new GeometryGroup();
for (int i = 0; i < numberOfPoints; i++)
{
int rad = r.Next(10) + 10;
gg.Children.Add(new EllipseGeometry(new
Point(r.NextDouble() * wd.Size.Width, r.NextDouble() * wd.Size.Height), rad,
rad));
if (e.Cancel == true)
return;
}
GeometryDrawing gd = new GeometryDrawing(null, new
Pen(Brushes.Black, 1), gg);
DrawingBrush db = new DrawingBrush();
db.Drawing = gd;
db.Freeze();
e.Result = db;
}
}
}
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
{
base.OnRenderSizeChanged(sizeInfo);
if (bgworker.IsBusy)
bgworker.CancelAsync();
bgworker.RunWorkerAsync(new WorkData(sizeInfo.NewSize));
}
}
class Win : Window
{
public Win()
{
Content = new DrawingPanel();
}
}
class App : Application
{
[STAThread()]
static void Main()
{
new App();
}
App()
{
Run(new Win());
}
}
} Tag: some computer langauages Tag: 138089
Multiple versions of framework at the same time
What happens if I write a .net program using the framework 3.5 and I use a
2.0 dll? Are both frameworks (3.5 and 2.0) loaded at the same time "eating"
more memory, or does the 2.0 dll uses the 3.5 framework?
--- thanks Tag: some computer langauages Tag: 138083
Problem with SHA256Managed when running multi-threaded
Hi,
I am experiencing problems with the SHA256Managed class when multiple
threads are simultaneously using it. I have reduced the problem to a small
piece of code (see below). This creates two threads, each of which repeatedly
attempts to hash a string and compare the result to a previous attempt. After
a number of tries, the result coming back is different. Running a single
thread or locking the hashAlgo object stops the problem. However, this
shouldn't be necessary as the documentation states that this class is thread
safe when using a static instance.
--- Code example:
using System;
using System.Security.Cryptography;
using System.Text;
namespace HashTester
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 2; i++)
{
System.Threading.Thread ff = new System.Threading.Thread(new
System.Threading.ParameterizedThreadStart(HashTestFn));
ff.Start("pa$$word");
}
}
private static void HashTestFn(object o)
{
HashTest test = new HashTest(o.ToString());
for (int i = 0; i < 10000; i++)
{
test.Test();
}
}
}
class HashTest
{
private static HashAlgorithm hashAlgo = new
System.Security.Cryptography.SHA256Managed();
private string input;
private string output;
public HashTest(string toHash)
{
input = toHash;
byte[] hashBytes;
hashBytes = hashAlgo.ComputeHash(Encoding.ASCII.GetBytes(input));
output = Convert.ToBase64String(hashBytes).ToUpper();
}
public void Test()
{
byte[] hashBytes =
hashAlgo.ComputeHash(Encoding.ASCII.GetBytes(input));
string newOut = Convert.ToBase64String(hashBytes).ToUpper();
if (newOut != output)
{
throw new Exception("Bad Hash!!!!");
}
}
}
} Tag: some computer langauages Tag: 138080
How server app can publish multiple Interface as Remoting on separate
How Marshal the each Interface on two separate tcp ports channel?
this is very often request, we have application that run as service.
and we need to control it from within the office
on separate port than client connect to get service (for add
security).
for example:
============
I have server (run as windows services) app that have two kind of
service:
interface1: for outside users on 50032 port
interface1: second on 50033 port only for internal use (for
Control Mng on this service)
the two Interface (interface1 & interface2) share same Class
instance.
So I register two channel of tcp (the second one: props("name") =
"tcp2" to avoid error: "already exists"),
But how I can Attach each Marshal to each Port?
some one wrote that need make it on two DomainApp, but how do that
with one Class instance? Tag: some computer langauages Tag: 138074
lambda question
Hi,
I have a question related to lambda expresions and how to prevent exceptions in a FindAll().
The following code create a list of objects and search for an item the "old" way and the "new" way:
Create the list.
List<object> list2 = new List<object>() { 1, 2, null, 6 };
Search for item "6" the old way.
List<object> temp4 = list2.FindAll(delegate(object obj)
{
if (null != obj)
{
return object.Equals(obj.ToString(), "6");
}
else
{
return false;
}
});
Search for item "6" the new way.
List<object> temp3 = list2.FindAll(obj => object.Equals(obj.ToString(), "6"));
The first method goes just fine because i'm able to check for null items.
The second method fails because of the null item.
How do i check for null items in the second method ??
Thank you in advance.
BR
Peter Tag: some computer langauages Tag: 138073
Error occurred while initializing fusion (Error 25007)
I can't install .Net Framework (either 1.1, 2.0 or 3.0)
After a new installation of Windows XP Pro on an HP Workstation xw4200
machine it keeps giving me errors and can not get it to install.
I have tried a few things already that were on the MS KB site but nothing
worked so far. Also deleted my graphics drivers (ATI) but to no avail.
Would anyone know what to do?
Regards,
Patrick Tag: some computer langauages Tag: 138072
Read() on ResponseStream of a HttpWebRequest always returns zero
Hi,
I have to check if a url like http://my_server/abc.aspx?id=123 sends a
valid file. The server always returns OK as status code, but sends
emtpy files, if the id is not correct. It's not possible for me to
change the server side. Content-Lenght is always zero, because files
are in a streaming format (I think).
I tried to read the first 10 bytes of the file to check if it contains
some valid data, but Read(...) returns zero bytes even for the valid
ids. If I try the same url in IE, I'm able to download the file.
Any hint what I might be doing wrong? Or another way to check the
files?
regards,
Achim Tag: some computer langauages Tag: 138063
Deployment of a Windows application
Hi
I've just finished testing a Windows application (C# 2005), composed of a
.exe and many .dll, and I've to deploy it. Question: how can I avoid the dlls
deployed with the application being open source, i.d. consumable by other
applications (not mine) simply adding the dlls as references to these
applications? Tag: some computer langauages Tag: 138059
ildasm
I invoked ildasm, couldn't figure out what it was doing, and invoked it
again. Here's a screenshot of the twins:
http://www.geocities.jp/hitotsubishi/ildasm.png
What is the one on the left doing? Tag: some computer langauages Tag: 138054
Framework retro compatibilty
Hi,
I know it's possible to call a Framework 3.5 compile dll in a with a
Framework 2.0 compile executalbe for exemple. Is it supported and recommended
???
And what about with a 1.1 Framework execuable??
Thank for your help.
--
Nico Tag: some computer langauages Tag: 138047
Crystal Report Error with datasource of linq-to-sql classes
I have a crystal report that i added datasources to that are classes made
from linq-to-sql designer.
This report errors trying to find logon info when i tell it export data or
use it in a viewer. There is no logon info so whats up?
I am settings the SetDataSource method with the object returned from the
LINQ query. Here's the code. The report simply has the .net object classes i
selected from the available data sources.
ABBDBDataContext db = new ABBDBDataContext();
IEnumerable<Order> o = from t in db.Orders
where t.ID == orderid
select t;
if (o == null)
return;
ABB.Reports.Invoice inv = new ABB.Reports.Invoice();
inv.SetDataSource(o);
inv.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,
"c:\test.pdf"); Tag: some computer langauages Tag: 138043
.NET Compact Framework - Better with C#, not VB?
According to this article, if using VB FileSystem I/O isn't supported.
http://msdn2.microsoft.com/en-us/library/t340010s.aspx
Does this mean that if using C# it is supported? Or does it only mention VB
but it applies to all languages?
Also, all the links on this page only refers to VB, not C#. Is there a
difference between the 2 when programming in the .NET compact environment?
Thanks Tag: some computer langauages Tag: 138038
Best Book for WorkFlow
In the past I worked for an Insurance Distribution company who developed
workflow software. I understand workflow quite well but have not been able
to get an understanding of it in .NET. Whet is the best book for a beginner
and the best book for reference for .NET Workflow. Iâ??m developing the
application using C# .NET 3.5 with LINW to SQL.
Thank You!
Alexander L. Wykel Tag: some computer langauages Tag: 138037
Locate ending bracket in VS for obfuscated code !
Hi,
I am using Visual Studio 2005 to debug a program. It is like
obfuscated code, so I wonder if given a starting bracket, VS can tell
me where the closing bracket is.
By the way, I also wonder if this is the right group to ask these
questions. Otherwise suggestions are welcome !
Thanks in advance Tag: some computer langauages Tag: 138029
distribuzione di un'applicazione
Ho finito di sviluppare un'applicazione Windows (C# 2005), composta di un
.exe di avvio e vari .dll, e la devo distribuire. Domanda: come faccio a
impedire che le dll che distribuisco insieme allâ??applicazione siano open
source, cioè utilizzabili per un altro progetto (non mio) semplicemente
aggiungendole come riferimento a questo progetto? Tag: some computer langauages Tag: 138028
LINQ question
This is a multi-part message in MIME format.
------=_NextPart_000_00EE_01C884E8.00DD6E90
Content-Type: text/plain;
format=flowed;
charset="iso-8859-1";
reply-type=original
Content-Transfer-Encoding: 7bit
I have a desktop aplication which use an embeded database engine (embeded in
the application that is) to store its data.
And I used LINQ 2 SQL as an ORMapper to synchronize the database with my
object representation in memory.
What I want to do is load most object at the start, do in memory work, and
occasionaly load additional big data or save the changes.
I have a problem with the DataContext.GetTable<T>() mehod. It seems
everytime I do a foreach on its retur it will query the database, is that
true?
So in my particular case I'm better off working with an List<T> which I will
initialize from the GetTable<T> result?
Just in case I wrote such a list (Code attached) and I wonder if I did it
the proper way, if anyone can take a look?
Also I have a table like that
Data
--------
ID int
summary nvarchar(256)
content image
which I loaded in
[Table("Data")]
class Data
{
[Column(...)]
public int ID {get; set; }
[Column(...)]
public sring Sumary { get; set; }
[Column(...)]
public byte[] Content { get; set; }
}
Now Content is potentially big and I want to use lazy loading, i.e. I DON'T
want to load the 'byte[] Content' with the rest of the data (I guess it's
easy, just remove the ColumnAttribute), but I DO want to save the Content,
if it's not null (i.e. if it has been explicitely loaded/set/modified) when
SubmitChanges() is called on the Context.
Any tip on how to do that?
Moreover, if I only change the content (which will have no ColumnAttribute)
how do I mark my entity as dirty in the context? (i.e. I would need an
'UpdateOnSubmit()' method in the table, but it doesn't exists..)
------=_NextPart_000_00EE_01C884E8.00DD6E90
Content-Type: text/plain;
format=flowed;
name="LinqList.cs";
reply-type=original
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="LinqList.cs"
=EF=BB=BFusing System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace Galador.Utils.SQL
{
/// <summary>
/// This will hol an in memory representation of some LINQ data.
/// All data will be loaded at creation time and furter work would
/// be done in memory.
/// </summary>
/// <typeparam name=3D"T"></typeparam>
public class LinqList<T> : IList<T>
where T : class
{
List<T> data;
public LinqList(DataContext ctxt)
{
if (ctxt =3D=3D null)
throw new ArgumentNullException("ctxt");
data =3D new List<T>(ctxt.GetTable<T>());
}
public LinqList(DataContext ctxt, Expression<Func<T, bool>> predicate)
{
if (ctxt =3D=3D null)
throw new ArgumentNullException("ctxt");
data =3D new List<T>(ctxt.GetTable<T>().Where<T>(predicate));
}
public LinqList(DataContext ctxt, Expression<Func<T, int, bool>> =
predicate)
{
if (ctxt =3D=3D null)
throw new ArgumentNullException("ctxt");
data =3D new List<T>(ctxt.GetTable<T>().Where<T>(predicate));
}
public LinqList(DataContext ctxt, Func<T, bool> predicate)
{
if (ctxt =3D=3D null)
throw new ArgumentNullException("ctxt");
data =3D new List<T>(ctxt.GetTable<T>().Where<T>(predicate));
}
public LinqList(DataContext ctxt, Func<T, int, bool> predicate)
{
if (ctxt =3D=3D null)
throw new ArgumentNullException("ctxt");
data =3D new List<T>(ctxt.GetTable<T>().Where<T>(predicate));
}
public DataContext Context { get; private set; }
#region IList<T> Members
public int IndexOf(T item)
{
return data.IndexOf(item);
}
public void Insert(int index, T item)
{
if (item !=3D null)
Context.GetTable<T>().InsertOnSubmit(item);
data.Insert(index, item);
}
public void RemoveAt(int index)
{
T item =3D data[index];
if (item !=3D null)
Context.GetTable<T>().DeleteOnSubmit(item);
data.RemoveAt(index); ;
}
public T this[int index]
{
get { return data[index]; }
set
{
RemoveAt(index);
Insert(index, value);
}
}
#endregion
#region ICollection<T> Members
public void Add(T item)
{
Insert(Count, item);
}
public void Clear()
{
Context.GetTable<T>().DeleteAllOnSubmit<T>(data);
data.Clear();
}
public bool Contains(T item)
{
return data.Contains(item);
}
public void CopyTo(T[] array, int arrayIndex)
{
data.CopyTo(array, arrayIndex);
}
public int Count
{
get { return data.Count; }
}
public bool IsReadOnly
{
get { return false; }
}
public bool Remove(T item)
{
int index =3D IndexOf(item);
if (index < 0)
return false;
RemoveAt(index);
return true;
}
#endregion
#region IEnumerable<T> Members
public IEnumerator<T> GetEnumerator() { return data.GetEnumerator(); }
#endregion
#region IEnumerable Members
System.Collections.IEnumerator =
System.Collections.IEnumerable.GetEnumerator() { return GetEnumerator(); =
}
#endregion
}
}
------=_NextPart_000_00EE_01C884E8.00DD6E90-- Tag: some computer langauages Tag: 138024
How to capture "printfs" from unmanaged C++
I posted this to the interop group. I'm reposting to troll for a few
more ideas.
In my managed C# app we capture trace statements and direct them to a
log file using trace listeners. Part of the app uses unmanaged C++
dlls, and unfortunately, the C++ printfs don't get picked up and are
simply printed to the console window.
Is there any way I can capture the output of the printfs and then
redirect them to the same file that the trace listener is writing to?
I do have access to the unmanaged C++ code if the solution involves
not using printfs. The important thing is that the C++ printfs and the
C# trace messages end up in the same file.
One solution from the interop group was to compile the C++ with /clr
and then replace the printfs with Trace.WriteLine(). Any less invasive
techniques. Maybe somehow redirecting the printfs to someplace that
can be picked up by .Net.
Thanks
Mitch Tag: some computer langauages Tag: 138023
Microsoft Office compatible with Mac and Pc
Hi there I am looking to buy MO 2007 Home and Student version. I have both a
PC and a Mac and would like to install a suite on both. Is this possible or
will I have to buy seperate packages?
Best wishes,
Pam Tag: some computer langauages Tag: 138012
.NET Windows Forms Security
How do I install a custom windows forms permission set and code group
without the SDK configuration tool? Tag: some computer langauages Tag: 138009
() in attribute declaration
I have seen attributes, specifically Serializable declared in 2 ways and was
wondering if anyone had any insight on the differance if there is any. These
2 ways are [Serializable] and [Serializable()]. Does the addition of the
parenthesis do anything? Is this calling a constructor? Both seem to have the
same effect in the end, but it seems like they should do something differnt? Tag: some computer langauages Tag: 138007
System.Timers.Timer and Close/Dispose
The short form of this post is as follows. For an instance of
System.Timers.Timer, after setting Enabled to False, is there a foolproof way
to tell if an Elapsed event will or will not fire?
The long form follows. I have a class, MyClass, that declares
Private WithEvents MyTimer As System.Timers.Timer
Sub New for MyClass initializes MyTimer to fire Elapsed events every second.
I have an Elapsed event handler and some public methods. With SyncLock,
I've made MyClass instances thread safe. Everything works fine.
System.Timers.Timer has Close and Dispose methods, so I when I want to
destroy an instance of MyClass, I should Close or Dispose MyTimer. I've
coded MyClass.Close to look like this:
MyTimer.Enabled = False
' some cleanup I need to do
Sleep(100) ' let fire an enroute MyTimer.Elapsed
MyTimer.Dispose() ' per IDisposable
' some more cleanup I need to do
The reason for the Sleep is because of how Windows/.NET executes
MyTimer.Elapsed events. The Timer.Stop documentation says:
"The Elapsed event is raised on a ThreadPool thread, so the event-handling
method might run on one thread at the same time that a call to the Stop
method runs on another thread. This might result in the Elapsed event being
raised after the Stop method is called."
Stop and Enabled=False do the same thing. The Timer.Stop documentation goes
on to give a somewhat elaborate mechanism to overcome contention and race
conditions that might arise. My solution is Sleep(100).
I don't like my use of Sleep. I don't like the elaborate mechanism in the
documentation because it looks like it could fail if someone is messing with
thread priorities (note that the mechanism uses Sleep(0)).
So, the question is: For an instance of System.Timers.Timer, after setting
Enabled to False, is there a foolproof way to tell if an Elapsed event will
or will not fire? Tag: some computer langauages Tag: 138004
Good C# profilers?
Hi...
I was just wondering what recommendations people had for C# code profilers?
I'm trying to figure out where a lot of our app's time is going.
I downloaded and am trying ProfileSharp Enterprise Edition, but I'm finding
the interface awkward and the results suspect (profiling for cpu cycles, it
says Thread.Sleep is the most expensive function).
Has anyone had particularly good experience with a C# code profiler?
Thanks
Mark Tag: some computer langauages Tag: 138003
EnterpriseLibrary.Logging
Hi all,
I have installed EnterpriseLibrary v3.1 (latest version) on my pc. When I
create the app.config file using the "EnterpriseLibrary Configuration"
utility, I get an error saying it can't detect the EL.Logging.dll file. I
fixed the problem by setting the PublicKeyToken= "null" instead of its
default PublicKeyToken="b03f5f7f11d50a3a".
eg.
configSections>
<section name="loggingConfiguration"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
Culture=neutral, PublicKeyToken=null" />
<section name="exceptionHandling"
type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings,
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=3.1.0.0,
Culture=neutral, PublicKeyToken=null" />
</configSections>
The thing is that I can't understnad why this error is occuring in the first
place. This pc is newly set-up and it has never had any prior versions of EL
installed on it. The "EnterpriseLibrary Configuration" utility comes with
this v3.1 setup.
Thanks for your reply.
regards,
Andrew Tag: some computer langauages Tag: 137998
GDI and Rotating Text
Hi,
I want to use GDI to rotate some text at an angle and output the
resultant image to the asp.net response stream.
I can do that all fine, however what I'm struggling with is trimming
the whitespace from the resultant image.
What im doing is creating a blank canvas image (of arbitrarily large
size) and doing a translate transform to the centre, then applying a
rotate transform, then writing my text.
What i want to do is trim all the whitespace from around the edges. Is
there some way i can determine the width and height of the text ive
written to the image (after the transform) ?
I know i can manually get the text dimensions before the rotate, then
use some trig to work out how high and wide it would be after rotating
it but thats a bit of a pain if theres some function that will do it
for me
Thanks for any advice
Andrew Tag: some computer langauages Tag: 137996
Fold and unfold easily code
Hi,
I am looking for some addin-plugin-external tool for Visual Studio
2005 that would allow me to fold/unfold parts of the code in an easy
way. I don't like the default VS fold mode, its behavior is usually
unpredictable for me.
Thanks Tag: some computer langauages Tag: 137995
System.Net.Mail issue
Hi,
I'm using System.Net.Mail to send email in C#.
When I have word "do not" in the mail's body, I couldn't get the mail.
THis is wired, any idea?
Thanks.
William Tag: some computer langauages Tag: 137987
framerwork distriburion - licence
I'd like to distribute the .NET framework with my application. I'm
wondering about the license. My application is being created with
Borland Delphi 8 (with .NET) - I've the license for that product. So
the question is: may I distribute the .NET framework with my app?
I was trying to find this information on the Microsoft's web page -
but I've found it impossible.
Please help me,
cezar Tag: some computer langauages Tag: 137984
Windows service startUp error
Hi all,
My question consists of 2 parts:
1) I have installed my windows service [by right-click on Setup.exe in
SolutionExplorer, then Install ... ] onto a folder on my desktop. When I
click on the MyNewService.exe file, I got the following error message:
" Cannot start service from the command line or a debugger. A Windows
Service must first be installed (using installutil.exe) and then started with
the ServerExplorer, Windows Services Administrative tool or the NET START
command. "
2) Is the problem because I need to install using "installutil /i
C:\MyNewService3.exe" ?
I tried that and i got the error message:
" Exception occurred while initializing the installation:
System.IO.FileNotFoundException:
File or assembly name Documents, or one of its dependencies, was not found. "
Any advice on understanding what this message says ?
Thanks.
regards,
Andrew Tag: some computer langauages Tag: 137978