|
:smirk: Leave it to me to answer my own question eventually. Just in case someone out there runs into the same problem that I did I guess I will throw this out there.
It turns out that DirectSound Secondary buffers can perform Effects Processing... but in order to do so the sound file must be at LEAST a certain size. Since I am loading tiny .wav files the bufferTooSmall exception is getting tossed.
The buffer size is not great enough to enable effects processing.
So now the question is thus, will disabling effects processing be enough to make this error go away? Or can I just catch it and ingore it?
|
|
|
|
|
I have created this C#.NET windows services. This windows service watchs the file system to see if any word documents has been changed or moved directories. This it has then it puts a timestamp sentence in the word document.
This problem is this. I created a C#.net dll or the word portion or the application. Now when I test this dll out with a windows application it works great. But when I call the dll from my windows service it seems to hang. The winword.exe just hangs and so the does the code in the dll. Does anyone know why?
Nicholas Ingratta
ningratt@hotmail.com
|
|
|
|
|
The service needs to run either as a particular user (not the default SYSTEM) or has to be able to interact with the desktop (if a user is currently logged in; the former approach is better if you don't want to require that the machine be logged into 24/7/365.25).
If you're using the ServiceInstaller and ServiceProcessInstaller , you can do this in code (NEVER hard-code your password; accept it from the command-line where the parameters are passed to you through the Context.Parameters property (Context is actually a property of the Installer class, which you extend for your own installer).
If there is no window station associated with the user context, the Windows application cannot start (there's no window manager).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
in my project I have serviceProcessInstaller1. If I look at the properties which ones to I have to change then.
This does not really make sense to me since this is windows service and a user may never log in or a desktop ever be used.
Is there anyway you could walk me through some of the steps. Thanks for the help
Nicholas Ingratta
ningratt@hotmail.com
|
|
|
|
|
It should be obvious: Username and Password .
It makes perfect sense if you understand Windows. Word is a Windows program. Whether or not it is visible, it requires a Window manager. If a service isn't associated with a user login - or can't interact with the currently logged in user - there's no window manager and the Windows program (i.e., Word) won't run.
So, you need to run your service as a user that can log in interactively. This doesn't mean that a login session as you'd normally see it as a human user would exist, just that the system impersonates the user given their credentials and creates a window station under that user's contect. This is necessary.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I tried what you said and that worked great. Word actually will run and not hang. But now I seem to have another issue. My word class for some reason gets an error everytime I try to add a paragraph at the end of the document. The error I recieved is "The Server threw an exception". Here is my code. I guess I am doing something wrong. It always fails that the with wordPara.Range.Text = "whatever". Could you help me out again.
wordApp = new Word.ApplicationClass();
wordApp.Visible = (bool) isVisible;
if ( wordApp != null )
{
wordDoc = wordApp.Documents.Open(ref _fileName,ref missing,
ref readOnly,ref missing,
ref missing,ref missing,ref missing
,ref missing, ref missing
,ref missing, ref missing,
ref isVisible,ref missing,
ref missing, ref missing);
object wordRng = wordDoc.Bookmarks.Item(ref oEndOfDoc).Range;
string strDateTime = DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/" + DateTime.Now.Year.ToString() + " "
+ DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString();
Word.Paragraph wordPara;
wordPara = wordDoc.Content.Paragraphs.Add(ref wordRng);
//it fails right after this comment
wordPara.Range.Text = "Original electronically authenticated by " + physName + " on " + strDateTime;
wordPara.Range.Font.Bold = 1;
wordPara.Range.InsertParagraphAfter();
if ( sign && ( signLocation.Length > 0 ) )
{
wordRng = wordDoc.Content.Paragraphs.Last.Range;
wordDoc.Content.InlineShapes.AddPicture(_fileSignature, ref missing
,ref missing, ref wordRng);
}
wordDoc.Save();
wordDoc.Close(ref missing, ref missing, ref missing);
wordApp.Quit(ref TBoolean, ref missing, ref missing);
Nicholas Ingratta
ningratt@hotmail.com
|
|
|
|
|
IIRC, you have to create a range first. The range would be over the paragraph you added, but, by default, does not encompass the paragraph. Again, IIRC.
The best thing to do is read the VB documentation for Word (the very same objects and types that VB6 uses (automation objects) are the same that the .NET RCW (runtime-callable wrapper) uses, though in a few cases classes may be represented a little differently).
In the future, when you start a new question (and this is a new - but related - question), please post a new question.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I thought this code
object wordRng = wordDoc.Bookmarks.Item(ref oEndOfDoc).Range;
already creates the range
|
|
|
|
|
It may. Like I mentioned, you should read the VB documentation for the Word object model (the best place is in the Word help itself if you installed the developer documentation; the documentation - if you can find it - in the MSDN Library isn't very specific (and like I implied, hard to find the right docs)).
If the COM server (Word) is throwing an error, though, something isn't right. Based on your code it seems similar to a NullReferenceException in .NET, except that your proxy object isn't null but the associativity of it may be empty in the Word COM server. That's why the Range object came to mind first.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I printed out the stack trace it looks like this
at Word.Range.set_Text(String prop)
at com.vmi.CardioIMS.Document.WordClass.SignDocument(String docName, String docLocation, String physId, String physName)
Nicholas Ingratta
ningratt@hotmail.com
|
|
|
|
|
What is this: com.vmi.CardioIMS.Document.WordClass.SignDocument ? If you use the official Primary Interop Assemblies for Word 10 (XP) from MSDN[^] you would not see this. This looks like some third-party solution (perhaps part of your solution).
Using official PIAs from the COM server publisher is always a good idea and, when installed (i.e., for Office XP PIAs run the batch file to register them correctly), get used any time you would normally create your own. These are tested and, sometimes, may even be custom RCWs.
Office 2003 will be compatible in most cases with the XP typelib (where your RCW comes from) but do install their own PIAs if you choose ".NET Framework Developer Support" as a feature. Generally, using older typelibs for properly implemented COM servers (like Office) will support newer implementations unless older interfaces have been deprecated (happens rarely in Office; the basic stuff has almost always been around).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
com.vmi.CardioIMS.Document.WordClass.SignDocument is just a class that uses the Micrsoft Word 10.0 object library to open up word and add a paragraph.
I am just frustrated since this code was working before. You do not need to use the Interop Assemblies. Plus the code I am partially using is from a Microsoft web site.
Nicholas Ingratta
ningratt@hotmail.com
|
|
|
|
|
Yes, you do need to use Interop assemblies. That is what you're doing. .NET is not a COM client and requies a wrapper. you can write your own RCWs, but they're required nonetheless. The PIAs I'm talking about are from Microsoft and tested. The interop assemblies you created when you referenced the Word 10 library in Add References (VS creates them automatically; just expand your References under your project) are probably the same but, unless you set up your signing key in the project under VS, are not signed (meaning that stricter code access policies may block the interop assemblies from being loaded).
Again, it's only a recommendation to use PIAs. Either way you're using interop assemblies.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Yeah, I'm stuck with a similar issue The only way to interact with desktop is either using localsystem, or user, but user doesnt allow interactive startup either it appears.
Found this on MSDN:
ServiceType Enum
The creation of interactive services is not supported. To workaround this, you can create a non-interactive service and a separate control GUI application that communicates with the service using sockets or remoting. For code samples on remoting, see Remoting Examples.
So it seems you will still need some form of extra application...
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
Impersonating an interactive user account (or anything but SYSTEM) disables "Allow service to interact with desktop") because it's already assumed that the user is an interactive user (to be an interactive user, they must have the SE_INTERACTIVE_LOGON_NAME right).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
i'm a .NET newbie and hope someone can help me. I try to build something like an applet (Java) with C# and .NET. I've been told this can be done by a windows forms control assembly embedded in a html page via the well known <object> tag. Indeed, everything works fine except the control's database access to a local database. Here i get the exception "SQLClientPermission denied". I'm sure the problem lies in the CLR access policies for the code of the embedded control (coming from the intranet zone). Can anyone tell me how to grant this SQLClientPermission to the code of my control?
Thanks for your help,
Fridtjof
|
|
|
|
|
Control Panel->Administrative Tools->Microsoft .NET Framework 1.1 Wizards->Trust an Assembly
Any remotely useful information on my blog will be removed immediately. There are 10 kinds of people in the world. Those who have heard of the ubiquitous, overused, worn-out-like-an-old-shoe binary "joke" and those who haven't.
Judah Himango
|
|
|
|
|
I would suggest you check into Code Access Security[^] (part of the .NET Framework Developer's Guide). Using the .NET Framework 1.1 snap-in for the Microsoft Management Console, you can evaluate what permissions apply to a particular assembly under the "Runtime Security Policy" and then selecting "Evaluate Assembly". Within the security policy section you are able to make many other changes as well as adjusting the security zone and increasing the level of trust for a particular assembly. This should get you started.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hello.
I have a web C# project with a form with 3 buttons and 3
placeholders, each placeholder contains a Web User Control,
when I click over button 1 it shows the data of WUC1, when
I click over button 2 it shows the data of WUC2 and when I
click over button 3 it shows the data of WUC3. My solution
was to make initially invisible the 3 placeholders and when
a button is clicked then I made visible the corresponding
placeholder, as the following code from button 1 shows:
this.PlaceHolder1.Visible = true;
this.PlaceHolder2.Visible = false;
this.PlaceHolder3.Visible = false;
This works well, but I think it's not too eficient to have
loaded the 3 WUCs, so I'm trying to make a dynamic load of
each WUC depending the button clicked, example of button 1:
private void btn1_Click(object sender,
System.EventArgs e){
this.PlaceHolder1.Controls.Clear();
this.PlaceHolder2.Controls.Clear();
this.PlaceHolder3.Controls.Clear();
this.PlaceHolder1.Controls.Add(LoadControl("WUC1.ascx"));
//Only load the WUC1
}
This code load well the WUCs, show the data, but it can't
execute the events of the WUCs, because in each WUC I have
buttons that perform some operations and this events don't
execute, i put a breakpoint and show that the page_load of
the page that contains the WUCs, I think it's a problem of
dynamic load of controls, any idea would be appreciated.
Thanks a lot.
|
|
|
|
|
|
Hi all,
After I loaded a dll component(c#)and use it in the program,
how can I destroy it(remove it from memory) in C# ?
Thanks
|
|
|
|
|
You will need to load the assembly into another AppDomain[^] and then use the static method AppDomain.Unload to remove it when you are done.
- Nick Parker My Blog | My Articles
|
|
|
|
|
I have this code in a C# class library
[Conditional("DBC_CHECK_ALL")]<br />
public static void Assert(bool assertion)<br />
{<br />
ExceptionAssert(assertion);<br />
TraceAssert(assertion);<br />
}<br />
<br />
[Conditional("DBC_USE_EXCEPTIONS")]<br />
static void ExceptionAssert(bool assertion)<br />
{<br />
if (!assertion) throw new AssertionException("Assertion failed.");<br />
}<br />
<br />
[Conditional("DBC_USE_ASSERTIONS")]<br />
static void TraceAssert(bool assertion)<br />
{<br />
Trace.Assert(assertion, "Assertion failed.");<br />
}
which is attempting to implement Anding of attributes as per this topic
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vclrfconditional.asp[^]
However, when I define either or both of DBC_USE_EXCEPTIONS or DBC_USE_ASSERTIONS in a Console app. that uses the library neither ExceptionAssert nor TraceAssert gets called.
Note: when all this is done within a single console app. it works OK.
Kevin
|
|
|
|
|
In .NET Compact Framework, System.Threading.Monitor.Wait(Object obj) and
System.Threading.Monitor.Pulse(Object obj) are not available. Does anyone know to use these functions or replace by other functions in .NET Compact Framework? Really Thanks a lot!!!!!
|
|
|
|
|
Hi everybody,
now for something completely different
I just read an article on pathfinding here on CP(http://www.codeproject.com/csharp/CSharpPathfind.asp) but it did not really get me started as I am too dumb to convert this to 3D
MY PROBLEM:
I have to write a program which checks if there is a path through a threedimensional cube, which consists of smaller cubes (scubes)
The cube dimensions are fixed (20x20x20 scubes) and each scube may be filled or void.
The is one variable, p, which determines the probability of a scube being filled (p) or being a void (1-p). This does not change as we iterate through the scubes on startup.
I have this cube ready to go and should now determine if there is a path from the top side to the bottom side.
Movement Rule: No Diagonal Moves, only along the three axis.
I smell recursion here, but I can't figure out how to do this
If I had some Lego(tm) here, I might have BUILT a cube and found a solution, but right now all I have is one sheet of paper and a pencil.
Can anyone get me back on track?
Cheers
Sid
|
|
|
|